+
    Uj                       R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	t	^ RI
t^ RIt^ RIt^ RIHt ]P                   P#                  ^ ]! ]! ]4      P)                  4       P*                  4      4       ^ RIHt ^ RIHtHtHt ^ RIHt ^ RIHtH t  ^ R	I!H"t" ^ R
I#H$t$ ^ RI%H&t& R R lt'R R lt(R R lt)RR R llt*R t+],R8X  d
   ]+! 4        R# R# )u(  Scene-only DinoVolumeScene training loop — single arm, no wrist.

Per-step losses: volume CE (pixel + height) + gripper CE + K-means rotation CE.
Per-vis: PCA of refined features, GT-vs-pred keypoints overlay, per-T heatmap
grid, and per-(T, bin) heatmap grids for rotation / gripper / height.

Checkpoint payload (everything inference needs to unpack predictions):
  - ``model``         state_dict
  - ``opt``           state_dict
  - ``step``          int
  - ``args``          dict (CLI args)
  - ``dataset_cfg``   includes rot_centroids (K, 4) + bin-range configs

Run on puget (GPU)::

    ssh dev
    source ~/yam_para/.venv/bin/activate
    cd ~/lab/para/robot/yam
    CUDA_VISIBLE_DEVICES=0 nohup python train.py --name <run> \
        --data_root ~/yam_para/data/<dataset> > /tmp/train.log 2>&1 &
)annotationsN)Path)
DataLoader)ArViewScene)DinoVolumeSceneDinoVolumeScenePerVoxel
all_losses)bin_grid_panel)feature_pca_panelshared_feature_pca_panels)marginal_heatmap_grid)height_curve_panel)keypoints_overlayc               (    V ^8  d   QhRRRRRRRR/# )   xyz_wz
np.ndarrayKT_w2cimg_sizeint )formats   "(/data/cameron/repos/smithbot_v4/train.py__annotate__r   .   s)     
 
 

 
: 
&)
    c                z   \         P                  ! V P                  ^ ,          ^3V P                  R7      p\         P                  ! W.RR7      pW%P
                  ,          P
                  R,          p\         P                  ! VR,          RR4      pWP
                  ,          P
                  pVR,          V,          # )	u   Project ``xyz_w`` (T, 3) through one cam → image-size pixel coords (T, 2).
Caller should clip + treat as drawing coords; in-frustum mask is implicit
in clipped values. Assumes K is already scaled to img_size×img_size.dtypeaxisgMbP?N)NNN:N   N)r!   :r   r"   N)r!   :Nr   N)nponesshaper   concatenateTclip)	r   r   r   r   r$   xyz_hcamzuvws	   &&&&     r   _project_world_to_pixr-   .   s    
 77EKKNA&ekk:DNNE=r2E77?

e
$C
FT4(Auu9--Cu:>r   c                    V ^8  d   QhRRRR/# r   r   r   vis_nr   )r   s   "r   r   r   ;   s     a as a3 ar   c                   / p\        VR,          4      pVR,          P                  4       P                  4       P                  4       pVR,          P                  4       P                  4       P                  4       pVR,          P                  4       P                  4       P                  4       pVR,          P                  4       P                  4       P                  4       p	VR,          p
V
 Uu. uF.  qP                  4       P                  4       P                  4       NK0  	  ppV R,          pV P	                  R4      pV R	,          P                  4       P                  4       pV R
,          P                  4       P                  4       pV R,          P                  4       P                  4       pV R,          P                  4       P                  4       pV R,          P                  4       P                  4       pRV 9   d&   V R,          P                  4       P                  4       MRpRV 9   d&   V R,          P                  4       P                  4       MRpVP
                  w  ppppp\        \        VV4      4       EF  p. p. p. pV EF  pVR8X  dq   VP                  \        P                  ! VV,          W"3\        P                  R7      4       VP                  VV,          4       VP                  VV,          4       K{  VR8X  g   K  Ve
   VV,          MRpVe   Vf   K  VP                  \        P                  ! VW"3\        P                  R7      4       VP                  VV,          4       VP                  VV,          4       EK  	  V'       g   EK   VV,          P                  VR#4      p V P                  ^R7      p!V!VV,          ,          p"V!VV,          ,          p#V#V,          p$V#V,          p%VVV"V$V%R3,          p&VV,          p'. p(. p)\        VR\        V4       4       EFB  w  p*pVV*,          p+\!        V'VV*,          VV*,          V4      p,\!        V&VV*,          VV*,          V4      p-\#        V+P%                  4       V,RRR$^
R7      p.\#        V.V-R^R7      p.\&        P(                  ! ^V.P
                  ^,          ^3^\&        P*                  R7      p/\        P,                  ! V/V R%\        P.                  RR&^\        P0                  4       V(P                  \&        P2                  ! V/V..4      4       V)P                  VV*,          V,          P5                  ^^^ 4      4       EKE  	  \7        V)W"3R7      p0. p1\        \9        VR\        V4       V04      4       F  w  p*w  pp2\&        P(                  ! ^V2P
                  ^,          ^3^\&        P*                  R7      p3\        P,                  ! V3V R2R%\        P.                  RR&^\        P0                  4       V1P                  \&        P2                  ! V3V2.4      4       K  	  \&        P:                  ! V(4      p4\&        P:                  ! V14      p5\<        P>                  ! V4RRRRR#13,          4      VRV 2&   \<        P>                  ! V5RRRRR#13,          4      VRV 2&   \<        P>                  ! \A        VV,          VV,          R 7      RRRRR#13,          4      VR!V 2&   \<        P>                  ! \A        V	V,          VV,          R 7      RRRRR#13,          4      VR"V 2&   EK  	  V# u upi )'zMulti-view panel set: pred vs GT keypoints overlaid on EACH view's
image side-by-side, plus per-view PCA, plus the existing grip/rot
grids. Voxel-position lookup gives us the predicted world XYZ
DIRECTLY (no ray-cast); we then project that to each camera.viewsvolume_logitsvoxel_positionsgrip_logits
rot_logitsview_feat_maps_bgr_src_wrist_bgr_src
target_xyztarget_grip
target_rot_K_in_T_w2c_K_wristN_T_w2c_wristsceneinterpolationwristr   r!   Ffilled	draw_linecolor_override	radius_pxTrG   rI   r   皙?out_wh PCA (joint)viz/kp_gt_vs_pred_viz/pca_dino_mlp_targetviz/grip_grid_viz/rot_grid_r       rV   rV            r[   r[   )!listdetachcpunumpygetr%   rangeminappendcv2resize
INTER_AREAreshapeargmax	enumeratelenr-   r   copyr#   fulluint8putTextFONT_HERSHEY_SIMPLEXLINE_AAvstack	transposer   ziphstackwandbImager	   )6batchoutr   r0   panelsr2   vol	voxel_posgriprotr7   vview_feats_np
bgrs_scene
bgrs_wristr:   r;   r<   K_sceneT_w2c_scene	K_wrist_bT_w2c_wrist_bBr'   NZP_b	view_bgrsview_Ksview_Tswbgrflat	idx_jointnz_idxhwy_idxx_idxpred_xyz_worldgt_xyz_world	kp_stripsfeats_per_viewkbggt_pixpred_pixkpbarpca_imgs
pca_stripspcabar2	kp_concat
pca_concats6   &&&&                                                  r   _viz_batch_multiviewr   ;   s   
 FWE
o

%
%
'
+
+
-
3
3
5C%&--/335;;=I}$$&**,224D
l

"
"
$
(
(
*
0
0
2C)*N7EF~!XXZ^^%++-~MFz"J+,J|$((*002J&**,224K|$((*002JGn  "((*G/%%'--/K3=3Fj!%%'--/DI;IU;RE.)--/557X\MYYNAq"a3ua=!	AG|  JqMH;O<?NN"L Mwqz*{1~.g(2(>z!}D<9#4  D82F<?NN"L My|,}Q/0   1v~~a$KKQK'	q1u%!a% aa"1feUA#=>!!} 	eOS^45DAq1B*<WQZQYZF,^WQZQRU]^H"2779f,1U4CrSB #2x41MB''2rxx{A."((CCKKsWc.F.F3;;@RYYRy12!!-"21"5"?"?1a"HI 6$ -H#79
$SI)?%JKKAx377B		!a0"BHHEDKK<0'3;S;S3;;@biis45	 L IIi(	YYz*
+0;;yAtt7L+M#A3'(*/++jAtt6L*M"1#&' (-{{47;q>:1a2:F(Hs#$&+kk3q6*Q-8AttD'Fqc"#K "N Mk Gs   .4]c                    V ^8  d   QhRRRR/# r/   r   )r   s   "r   r   r      s     c c cC cr   c                   ^ RI HpHpHp / p\	        VR,          4      pVR,          P                  4       P                  4       P                  4       p	VR,          P                  4       P                  4       P                  4       p
VR,          P                  4       P                  4       P                  4       pVR,           Uu. uF.  qP                  4       P                  4       P                  4       NK0  	  ppV R,          pV P                  R4      pV R	,          P                  4       P                  4       pV R
,          P                  4       P                  4       pV R,          P                  4       P                  4       pV R,          P                  4       P                  4       pV R,          P                  4       P                  4       pRV 9   d&   V R,          P                  4       P                  4       MRpRV 9   d&   V R,          P                  4       P                  4       MRpV	P                  ^ ,          pV	P                  ^,          pV! V^ R7       Uu. uF/  pVP                  4       P                  4       P                  4       NK1  	  ppV! V4      P                  4       P                  4       P                  4       p\        \        VV4      4       EF  p. p. p. pV EF  pVR8X  dq   VP                  \        P                  ! VV,          W"3\        P                  R7      4       VP                  VV,          4       VP                  VV,          4       K{  VR8X  g   K  Ve
   VV,          MRp V e   Vf   K  VP                  \        P                  ! V W"3\        P                  R7      4       VP                  VV,          4       VP                  VV,          4       EK  	  V'       g   EK   V	V,          p!VV,          p". p#. p$. p%\!        VR\#        V4       4       EF  w  p&pVV&,          p'\%        V"VV&,          VV&,          V4      p(\%        V!VV&,          VV&,          V4      p)\'        V'P)                  4       V(RRR/^
R7      p*\'        V*V)R^R7      p*\*        P,                  ! ^V*P                  ^,          ^3^\*        P.                  R7      p+\        P0                  ! V+V R0\        P2                  RR1^\        P4                  4       V#P                  \*        P6                  ! V+V*.4      4       V$P                  VV&,          V,          P9                  ^^^ 4      4       VV&,          V,          p\*        P:                  ! VVP=                  4       ,
          4      p,V,\=        V,P=                  4       R4      ,          p,V,R,          P?                  \*        P.                  4      p-\        P@                  ! V-\        PB                  4      p.\        P                  ! V.W"3\        PD                  R7      p.\        PF                  ! V'RV.R^ 4      p/\*        P,                  ! ^V/P                  ^,          ^3^\*        P.                  R7      p0\        P0                  ! V0V R2R0\        P2                  RR1^\        P4                  4       V%P                  \*        P6                  ! V0V/.4      4       EK  	  \I        V$W"3R 7      p1. p2\!        \K        VR\#        V4       V14      4       F  w  p&w  pp3\*        P,                  ! ^V3P                  ^,          ^3^\*        P.                  R7      p4\        P0                  ! V4V R!2R0\        P2                  RR1^\        P4                  4       V2P                  \*        P6                  ! V4V3.4      4       K  	  \L        PN                  ! \*        PP                  ! V#4      R"R"RRR213,          4      VR#V 2&   \L        PN                  ! \*        PP                  ! V24      R"R"RRR213,          4      VR$V 2&   \L        PN                  ! \*        PP                  ! V%4      R"R"RRR213,          4      VR%V 2&   VV,          p5V5V5P=                  ^ RR&7      ,          p5\*        P:                  ! V54      p6V6\*        PR                  ! V6PU                  ^ RR&7      R4      ,          p6^p7^p8V7V,          p9\*        P,                  ! V8V9^3^\*        P.                  R7      p:. R3Op;\        V4       F  p<V<V7,          ^,           p=V<^,           V7,          ^,
          p>T8p?\        V6P                  ^ ,          4       F  p&\W        \Y        V6V&V<3,          V8^,
          ,          4      4      p@V@^8  d   K7  V;V&\#        V;4      ,          ,          pA\        PZ                  ! V:V=V?X@,
          3V>V?3VAR2R'7       V?V@,          p?K  	  K  	  \*        P,                  ! ^V9^3^\*        P.                  R7      pB^pC\!        VRV6P                  ^ ,           4       F  w  p&pV;V&\#        V;4      ,          ,          pA\        PZ                  ! XBXC^3VC^,           ^3VAR2R'7       \        P0                  ! VBVVC^,           ^3\        P2                  R(R1^\        P4                  4       VC^^\#        V4      ,          ,           ,          pCK  	  \L        PN                  ! \*        P6                  ! XBV:.4      R"R"RRR213,          4      VR)V 2&   \L        PN                  ! \]        V
V,          VV,          R*7      R"R"RRR213,          4      VR+V 2&   \L        PN                  ! \]        VV,          VV,          R*7      R"R"RRR213,          4      VR,V 2&   EK  	  0 R4mpDV R-,          P                  4       P                  4       pE\        \        VV4      4       EF@  p/ pFVP_                  4        F  w  p&pV&XD9   d   VXFV&&   K  \`        Pb                  ! V4      '       d   VVV^,            XFV&&   KA  \e        V\        4      '       dM   V'       dE   \`        Pb                  ! V^ ,          4      '       d"   V UCu. uF  pCVCVV^,            NK  	  upCXFV&&   K  VXFV&&   K  	  V! XF4      ^ ,          P                  4       P                  4       P                  4       pG\L        PN                  ! \]        VGPf                  XEV,          R*7      R"R"RRR213,          4      VR.V 2&   EKC  	  V# u upi u upi u upCi )5zv3 panel set: per-view marginal heatmap (t=0), per-view PCA, pred
vs GT keypoints projected to each view, grip/rot bin grids, and a
per-timestep view-dominance bar.
)v3_per_view_heatmapsv3_view_dominancev3_z_marginalr2   r   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   Nr@   )t_indexrA   rB   rD   FrE   TrJ   r   rK   g&.>g     o@皙?g333333?z heatmap (t=0)rL   rN   r!   rO   rP   zviz/heatmap_per_view_t0_r   keepdims)	thicknessg?zviz/view_dominance_rQ   rS   rT   target_zviz/z_grid_rU   rW   rZ   r    ))      <   )r   P   r   )r   r   x   )r   r   r   >   n_zpe_tpe_zr2   n_views	pred_size)4lib.model_volumetric_v3r   r   r   r\   r]   r^   r_   r`   r%   ra   rb   rc   rd   re   rf   ri   rj   r-   r   rk   r#   rl   rm   rn   ro   rp   rq   rr   expmaxastypeapplyColorMapCOLORMAP_INFERNOINTER_LINEARaddWeightedr   rs   ru   rv   rt   maximumsumr   round	rectangler	   itemstorch	is_tensor
isinstancer'   )Hrw   rx   r   r0   r   r   r   ry   r2   
chosen_xyzr|   r}   r~   r   r   r   r:   r;   r<   r   r   r   r   r   T_hplog_p_per_view_t0domr   r   r   r   r   r   r   r   r   heatmap_stripsr   r   r   r   r   r   hp_linhp_imghp_colorblendr   r   r   r   bar3dom_tdom_pcol_wHbar_wbar_imgpalettetx0x1y_curh_kcollegx	_no_batchr   out_bz_logsH   &&&&                                                                    r   _viz_batch_v3r      s
   
; ; FWE%&--/335;;=J}$$&**,224D
l

"
"
$
(
(
*
0
0
2C7:;K7LM7L!XXZ^^%++-7LMMz"J+,J|$((*002J&**,224K|$((*002JGn  "((*G/%%'--/K3=3Fj!%%'--/DI;IU;RE.)--/557X\MA			!	B %9a$HJ$Hb *002$H  J C
 
'
'
)
-
-
/
5
5
7C3ua=!	AG|  JqMH;O<?NN"L Mwqz*GNN;q>,Jg(2(>z!}D<9#4  D82F<?NN"L My|,gnn]1=M.N  #A!!}	eOS^45DAq1B*<WQZQYZF,^WQZQRU]^H"2779f,1U4CrSB #2x41MB''2rxx{A."((CCKKsWc.F.F3;;@RYYRy12!!-"21"5"?"?1a"HI #1%a(BVVBM*Fc&**,--Fun,,RXX6F((1E1EFHzz(X,@252B2BDHOOBXsA>E77BA2BbhhGDKK>2G114(!S[[: !!"))T5M":;7 6: -H#79
$SI)?%JKKAx377B		!a0"BHHEDKK<0'114(!S[[: biis45 L ,1;;ryy7KAqRVTVRVJ7W+X#A3'(*/++bii
6KAqRVTVRVJ6W*X"1#&'16IIn%aDbDj123)!-.
 AD11uEII1tI<dCCA
''1eQ-288<RrAUQBa!eu_q%8E5;;q>*%adq1u 5677a#g,./gECK'82u+"b2 +  ggr5!nb9eOU[[^45DAq!c'l*+CMM#1vB|SBGKKQRc.F.F3;;@1s1v:%%A 6 -2KKIIsGn%aDbDj1-3$QC() (-{{47;q>:1a2:F(Hs#$&+kk3q6*Q-8AttD'Fqc"#U "` IIZ $$&,,.H3ua=!IIKDAqI~a##Qq1u:aAt$$uqt/D/D0121AaAJ2aa   e$Q'..0446<<>$)KK5778A;71dd
C%EQC ! " Mk N J~ 3s   4u5uuc          
     ,    V ^8  d   QhRRRRRRRRRR/# )	r   r   r   r0   	per_voxelboolz_lofloatz_hir   )r   s   "r   r   r   E  s9     N NS N N N05NCHNr   c           
     J   RV9   d   RV9  d   \        WW#4      # \        VP                  R4      \        \        34      '       d$   \        VR,          4      ^8  d   \        WW#4      # / pVR,          P                  4       P                  4       P                  4       pVR,          P                  4       P                  4       P                  4       p	VR,          P                  4       P                  4       P                  4       p
VR,          P                  4       P                  4       P                  4       pV R,          pV R,          P                  4       P                  4       pV R	,          P                  4       P                  4       pV R
,          P                  4       P                  4       pV R,          P                  4       P                  4       pVP                  w  pppppVV,          p\        \        VV4      4       EF  p\        P                  ! VV,          W"3\        P                  R7      p\!        VV,          P#                  ^^^ 4      4      p\$        P&                  ! VRRRRR!13,          4      VRV 2&   VV,          RRRR!13,          P)                  \*        P,                  4      V,          pVV,          P/                  VR!4      pVP1                  ^R7      pVVV,          ,          pVVV,          ,          p\*        P2                  ! VV,          P)                  \*        P,                  4      V,          VV,          P)                  \*        P,                  4      V,          .^R7      p\5        VP7                  4       VRRR"^
R7      p \5        V VR^R7      p \$        P&                  ! V RRRRR!13,          4      VRV 2&   \9        VVV,          VRR7      p!\$        P&                  ! V!RRRRR!13,          4      VRV 2&   V'       dB   \;        VVV,          WVVR#R7      p"\$        P&                  ! V"RRRRR!13,          4      VRV 2&   MVVP=                  ^RR7      ,
          p#\*        P>                  ! V#4      p$V$V$PA                  ^RR7      ,          p$V$P/                  VVVV4      PA                  R$R7      p%\$        P&                  ! \C        \*        PD                  ! V%R,           4      VV,          R7      RRRRR!13,          4      VRV 2&   \$        P&                  ! \C        V	V,          VV,          R7      RRRRR!13,          4      VRV 2&   \$        P&                  ! \C        V
V,          VV,          R7      RRRRR!13,          4      VR V 2&   EK  	  V# )%a  Per-batch wandb panels. ``per_voxel=True`` swaps the marginal-Z bin
grid for a pred-vs-GT height-over-time line plot (the per-voxel model
doesn't have a separate height head).

Multi-view models (``out["views"]`` set) take a different path that
renders pred-vs-GT keypoints + PCA on EACH view's image, concatenated
horizontally. Required batch fields for multi-view: ``_bgr_src``,
``_wrist_bgr_src``, ``_K_in``, ``_T_w2c``, ``_K_wrist``,
``_T_w2c_wrist``, ``target_xyz``.
view_Fzr3   r2   r5   r6   	F_refinedr8   	target_yxr   r;   r<   rB   r!   NrP   r   FrE   TrJ   rO         ?)	cell_sizealphazviz/heatmap_grid_)pred_z_bins	gt_z_binsr   r   r   rM   zviz/height_curve_r   g-q=rQ   r   rS   rT   r    rU   )      )r   r"   )#r   r   r`   r\   tuplerj   r   r]   r^   r_   r%   ra   rb   rd   re   rf   r
   rr   ru   rv   r   r#   float32rg   rh   stackr   rk   r   r   r   r   r   r	   log)&rw   rx   r   r0   r   r   r   ry   rz   r|   r}   	feats_refbgrsr   r   r;   r<   r   r'   Zr   r   scaler   r   r   r   r   r   
pred_z_binr   r   r   gridhc	flat_normeprobs_zs&   &&&&&&&                               r   
_viz_batchr	  E  s    CO36U99#'''"T5M22s3w<7HA7M#E@@F
o

%
%
'
+
+
-
3
3
5C}$$&**,224D
l

"
"
$
(
(
*
0
0
2CK '')--/557IDk"&&(..0IZ $$&,,.H&**,224K|$((*002JIIMAq!QqLE3ua=!ZZQ(!5S^^T	! 6 6q!Q ?@*/++c!Q"*o*F"1#&' A,q$B$w'..rzz:eC1v~~a$KKQK'	1q5)
!a% 88b1f__RZZ85@!Qw..rzz:UBDJKMrwwy&',/>"N r8tqI+0;;r!Q"*~+F#A3'( %RQ1CH*/++d1a2:6F*G"1#&' $
/7{*.q,68B /4kk"Q4R4Z..IF&qc*+ txxQx>>Iy!A11t(D#D1ii1a+//V/<G(-rvvgo6x{KAqRVTVRVJW)YF[$% (-{{47;q>:1a2:F(Hs#$ ',kk3q6*Q-8AttD'Fqc"#[ "` Mr   c                 E  aa+aOaPaQ \         P                  ! 4       p V P                  R RR7       V P                  RRR7       V P                  R\        \        P
                  ! 4       R,          4      R7       V P                  RRR7       V P                  R	\        ^(R
7       V P                  R\        ^RR7       V P                  R\        RRR7       V P                  R\        RRR7       V P                  R\        RRR7       V P                  R\        ^ RR7       V P                  RRRR.RR7       V P                  R\        ^R
7       V P                  R\        ^R
7       V P                  R \        ^ R
7       V P                  R!\        ^ R
7       V P                  R"\        R#R
7       V P                  R$\        ^R
7       V P                  R%\        R&R
7       V P                  R'\        ^0R
7       V P                  R(\        R#R
7       V P                  R)\        ^R
7       V P                  R*\        ^R
7       V P                  R+\        RR,R7       V P                  R-\        RR.R7       V P                  R/\        ERPR
7       V P                  R0\        R1R
7       V P                  R2\        R3R4R7       V P                  R5\        ^dR
7       V P                  R6\        ^2R
7       V P                  R7R8R7       V P                  R9RR:R;7       V P                  R<R=R>R?7       V P                  R@R=RAR?7       V P                  RBR=RCR?7       V P                  RDR=RER?7       V P                  RFR=RGR?7       V P                  RHR=RIR?7       V P                  RJRKRKRL.RMR7       V P                  RN\        ^ ROR7       V P                  RP\        ^R
7       V P                  RQR=RRR?7       V P                  RSR=RTR?7       V P                  RUR=RVR?7       V P                  RWR=RXR?7       V P                  RYR=RZR?7       V P                  R[R=R\R?7       V P                  R]RR^R;7       V P                  R_R`RaR;7       V P                  RbRcRdR;7       V P                  Re\         P                  RfRgRh7       V P                  Ri\        RjRkR7       V P                  RlR=RmR?7       V P                  Rn\        ^R
7       V P                  Ro\        ^R
7       V P                  Rp\        ^ R
7       V P                  Rq\         P                  RRrRh7       V P                  RsRtRtRu.RvR7       V P                  Rw\        ^RxR7       V P                  Ry\        ^R
7       V P                  Rz\        R{R|R7       V P                  R}\        ^ R~R7       V P                  R\        ^@RR7       V P                  RRRR;7       V P                  R\        ^RR7       V P                  R\        ^@RR7       V P                  RR=RR?7       V P                  RR=RR?7       V P                  RR=RR?7       V P                  R\        ^ RR7       V P                  RR=RR?7       V P                  RR=RR?7       V P                  RR=RR?7       V P                  RR=RR?7       V P                  RR=RR?7       V P                  R\        ^RR7       V P                  RR=RR?7       V P                  R\        RRR7       V P                  RR=RR?7       V P                  4       oP\	        SPP                  4      SPP                  ,          pVP                  RRR7       RpSPP                  '       d   \        P                  ! SPP                  RRfR7      p\!        RSPP                   RVR,           R24       SPP"                  '       gA   VR,          R,          p\        V^ ,          4      \        V^,          4      uSPn        SPn        M\!        R4       SPP$                  e'   SPP&                  e   SPP$                  SPP&                  3MRpVe#   SPP(                  '       g   VR,          R,          MRpSPP(                  '       d   Ve   \!        R4       \+        \	        SPP,                  4      SPP.                  SPP0                  SPP2                  SPP4                  SPP6                  SPP8                  SPP:                  TSPP<                  SPP>                  3TSPP@                  '       d   SPPB                  MSPPD                  '       d   SPPF                  M^ R7      pVP$                  VP&                  uSPn        SPn        VPI                  4       pERQoOVO3R lp\K        VSPPL                  RSPPN                  RRVR7      p	\Q        SPPR                  SPPT                  SPPV                  SPPX                  SPP@                  SPPZ                  SPP\                  \_        SPPD                  4      .4      p
V
^8  d   \a        R4      hSPPD                  '       d   SPPD                  Pc                  R4      MRoQSPPR                  '       d   ^ RI2H3p TpEMSPPV                  '       d   ^ RI4H5p TpEMSPPX                  '       d   ^ RI4H6p TpEMSPP@                  '       d   ^ RI4H7p TpEMSPPZ                  '       d   ^ RI4H8p TpEMtSPP\                  '       d   ^ RI9H:p TpEMXSPPv                  '       d   SQ'       g   Q R4       h^ RI<H=p TpEM-SPP|                  '       d   SQ'       g   Q R4       h^ RI?H@p TpEMSPP                  '       d   SQ'       g   Q R4       h^ RIBHCp TpMSPP                  '       d   SQ'       g   Q R4       h^ RIEHFp TpMSPP                  '       d   SQ'       g   Q R4       h^ RIHHIp TpMSPP                  '       d   SQ'       g   Q R4       h^ RIKHLp TpMZSPP                  '       d   SQ'       g   Q R4       h^ RINHOp TpM0SQ'       d
   ^ RIPHQp TpMSPPT                  '       d   \        pM\        pSPPR                  '       d   SPP                  ^08X  d   ^ pMSPPX                  '       d   SPP                  ^08X  d   ^pMSPPT                  '       d   SPP                  ^08X  d   ^ pMSPP\                  '       d   SPP                  ^08X  d   ^ pMzSPP                  '       dA   SPP                  ^08X  d0   SPP                  SPP                  ,           SPP                  ,           pM(SQ'       d   SPP                  ^08X  d   ^ pMSPP                  pVSPnT        SPP\                  '       d   \        SPP.                  SPP6                  SPP2                  VSPP                  SPP                  SPP                  SPP                  SPP                  SPP8                  SPP:                  SPP4                  SPP$                  SPP&                  R7      pEMUSPPv                  '       g8   SPP|                  '       g&   SPP                  '       g   SPP                  '       Ed   \        ERR/ RSQbRSPP.                  bRSPP6                  bRSPP2                  bRVbRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP8                  bRSPP:                  bRSPP4                  bRSPP$                  bRSPP&                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPPF                  bRSPP                  bRSPP                  b pSPP|                  '       d   SPP                  VR&   SPP                  VR&   SPP                  '       d.   SPP                  VR&   SPP                  VR&   SPP                  VR&   SPP                  '       dK   SPP                  VR&   SPP                  VR&   SPP                  VR&   SPP                  e   SPP                  VR&   EMSPP                  '       EdK   \        ERR/ RSQbRSPP.                  bRSPP6                  bRSPP2                  bRVbRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP8                  bRSPP:                  bRSPP4                  bRSPP$                  bRSPP&                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPPF                  bRSPP                  bRSPP                  b pEMSPP                  '       d   \        ERR/ RSQbRSPP.                  bRSPP6                  bRSPP2                  bRSPP                  bRSPP                  bRSPP                  bRSPP8                  bRSPP:                  bRSPP4                  bRSPP$                  bRSPP&                  bRSPP                  bRSPP                  bRSPP                  bRSPPF                  bRSPP                  b pEMSQ'       Ed=   \        ERR/ RSQbRSPP.                  bRSPP6                  bRSPP2                  bRVbRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP8                  bRSPP:                  bRSPP4                  bRSPP$                  bRSPP&                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPP                  bRSPPF                  bRSPP                  b pMd\        SPP.                  SPP6                  SPP2                  VSPP                  SPP                  SPP                  SPP8                  SPP:                  R7	      pSPP@                  '       d   VP                  SPP4                  SPPB                  SPP                  SPP                  SPP                  SPP                  SPP                  SPP                  SPP                  SPP                  SPP                  R7       V! ERR/ VB P                  SPP                  4      p\!        RVP                   RV RSPP6                   R24       VEe   VR,          pSPP(                  '       d   V Uu. uF  pVP                  R4      '       g   K  VNK   	  ppVP                  4        UU u/ uF"  w  pp VP                  R4      '       d   K  VV bK$  	  ppp \!        R\        V4       R24       SPP"                  '       d   ERSp!V Uau. uFG  o\        ;QJ d    V3R lV! 4       F  '       g   K   RM	  RfM! V3R lV! 4       4      '       g   KE  SNKI  	  p"pVP                  4        UU u/ uF  w  pp VV"9  g   K  VV bK  	  ppp \!        R\        V"4       RV" R24       VP                  4       p#. p$/ p%VP                  4        Fy  w  op SV#9   dh   V#S,          P                  V P                  8w  dF   V$P                  SE\        V P                  4      E\        V#S,          P                  4      34       Kt  V V%S&   K{  	  V$'       dA   \!        R\        V$4       R24       V$R,           F  w  op&p'\!        RS RV& RV' 24       K  	  VEP                  V%RfR7      w  p(p)V('       d(   SPP(                  '       g   \!        RV(R,           24       V)'       d   \!        RV)R,           24       \!        ER SPP                   24       ERTp*VEP                  4        U+a+U u. uFa  w  o+p V EP                  '       g   K  \        ;QJ d     V+3ER lV* 4       F  '       g   K   RM	  RfM! V+3ER lV* 4       4      '       g   K_  V NKc  	  p,p+p V, U u0 uF  p E\	        V 4      kK  	  p-p VEP                  4        U u. uF-  p V EP                  '       g   K  E\	        V 4      V-9  g   K+  V NK/  	  p.p SPEP                  p/SPEP                  e   SPEP                  MSPEP                  p0SPEP                  SPEP                  ,          p1V0SPEP                  ,          p2\!        ER\        V.4       ERV/ER ERV0ER ER\        V,4       ERV1ER ERV2ER ERSPEP                   ERSPEP                   24       \        EP                  EP                  ER	V.ER
V/ERERERV/ERV0/ER	V,ER
V1ERERERV1ERV2/.4      p3ER VP3ER llp4E\        EP                  ! SPEP                  SPP                  E\!        SP4      ER7       \!        ERE\        EP"                  '       d   E\        EP"                  EP$                  MER 24       \!        ERV 24       VP3ER lp5ER VP3ER llp6SPP\                  '       d	   ^ ERI9Hp7 MRp7VPVQ3ER lp8SPP                  '       d	   ^ ERINHp9 MSQ'       d	   ^ ERIPHp9 MRp9\        EP,                  ! 4       ;_uu_ 4        E\/        E\1        V	4      4      p:V:ER,          P                  SPP                  RER7      p;V:ER,          P                  SPP                  RER7      p<SQ'       d   V8! VV:4      p=MV! V;V<3/ V5! V:4      BV6! V:4      B p=E\        EP2                  ! E\5        T:T=SPP4                  SPPT                  ;'       g!    SPPX                  ;'       g    SPP\                  SPP$                  SPP&                  ER 7      ^ ER!7       \!        ER"4       RRR4       ^ p>E\6        EP8                  ! 4       p?V>SPEP:                  8  Ed   V	 EF
  p@V@ER,          P                  SPP                  RER7      pAV@ER,          P                  SPP                  RER7      pBV@ER#,          P                  SPP                  RER7      pCV@ER$,          P                  SPP                  RER7      pDV@ER%,          P                  SPP                  RER7      pEV@ER&,          P                  SPP                  RER7      pFV3EP<                   F!  pGV4! V>VGER,          VGER,          4      VGER
&   K#  	  SQ'       dj   V8! VX@4      pHV@ER',          P                  SPP                  RER7      P                  4       pISPP                  '       d   V9! XHXIXEXF4      pJM|V9! XHXCXDXEXFXI4      pJMnV! XAXB3/ V5! X@4      BV6! V@4      B pHV7eC   X@ER',          P                  SPP                  RER7      P                  4       pIV7! XHXCXDXEXFVI4      pJME\?        XHXCXDXEXF4      pJV3EPA                  RER(7       XJER),          EPC                  4        V3EPE                  4        V>^,          p>E\6        EP8                  ! 4       pKRVKV?,
          ,          pLTKp?ER*V>ER+VL/pMV3EP<                   F'  pGVGER
,          XMER,VGEPG                  ERER-4       2&   K)  	  V3EP<                  ^ ,          ER
,          XMER
&   XJP                  4        F  w  op V EPI                  4       XMS&   K  	  V>SPEPJ                  ,          ^ 8X  ds   XMP                  E\5        X@XHSPP4                  SPPT                  ;'       g!    SPPX                  ;'       g    SPP\                  SPP$                  SPP&                  ER 7      4       E\        EP2                  ! XMV>ER!7       V>SPEPL                  ,          ^ 8X  Ed>   VER.,          pN\        EPN                  ! RVP                  4       ER/V3P                  4       RT>ER0E\!        SP4      RTER1SPPv                  '       d   ER2EM)SPP|                  '       d   ER3EMSPP                  '       d   ER4MSPP                  '       d   ER5MSPP                  '       d   ER6MSPP                  '       d   ER7MSPP                  '       d   ER8MSPPR                  '       d   ER9MSPP@                  '       d   ER:MSPPZ                  '       d   ER;MkSPPV                  '       d   ER<MVSPPX                  '       d   ER=MASPPT                  '       d   ER>M,SPPD                  '       d   ER?MSPP\                  '       d   ER@MERA/XN4       VNEPQ                  VERB,          4       \!        ERCV> ERDXJER),          EPI                  4       ERE ERFVJERG,          EPI                  4       ERE ERHVJERI,          EPI                  4       ERE ERJVJERK,          EPI                  4       ERE ERLXLERM ERN2RERO7       V>SPEP:                  8  g   EK	   EK"  	  EK'  R# u upi u up pi u upi u up pi u up p+i u up i u up i   + '       g   i     ELy; i(U  z--nameT)requiredz--data_rootz--ckpt_rootzyam_para/checkpoints)defaultz--wandb_projectyam_train_simplez--batch_size)typer  z--num_workersuL   Default bumped 4→8 since training is CPU-bound on JPEG decode at batch 40.)r  r  helpz--lrga2U0*3?z3Head LR (and backbone LR if --backbone_lr_mult==1).z--lr_minNzvTerminal head LR for cosine schedule. Default: same as --lr (constant LR). Set to e.g. 1e-5 with --lr_schedule cosine.z--backbone_lr_mult      ?u  Backbone LR = --lr * this. <1.0 protects pretrained DINO weights from being damaged by the fresh-head LR. The ablation experiment showed lr=2e-5 was the magic value for from-scratch — i.e. 0.1× of head-friendly 2e-4. Backbone min LR scales by the same factor.z--lr_warmupzkLinear-warmup iters for both groups (0 = no warmup). Recommended ~5%% of --max_iters for from-scratch runs.z--lr_scheduleconstantcosineu<   LR schedule after warmup. cosine = decay from lr → lr_min.)r  choicesr  z
--n_windowz--frame_stridez--n_height_binsz--n_gripper_binsz--n_rot_clustersr   z--pred_sizez
--img_sizei  z
--feat_dimz	--d_modelz
--n_blocksz--mlp_hiddenz--z_lou   Lower height bin edge (m). Default = auto-derive from dataset (min EE z − pad). Finetunes override with the source ckpt's range automatically.z--z_hizOUpper height bin edge (m). Default = auto-derive from dataset (max EE z + pad).z	--grip_loz	--grip_hig?z--max_itersi@  zbDefault sized so a fresh run finishes in ~70 min at 2 it/s (avoids overfitting on small datasets).z--ckpt_every_itersz--vis_every_itersz--devicecudaz--init_fromzPath to a checkpoint to initialize model weights from (finetune mode). Also reuses the source ckpt's K-means rot centroids so the rot_head stays calibrated.)r  r  z--per_voxel
store_truezUse DinoVolumeScenePerVoxel instead of DinoVolumeScene (per-voxel features, no factorized scoring, CLS-only input). Saves model_kind='dino_volume_per_voxel' in ckpt.)actionr  z--da3u&  Use DA3VolumeScene (Depth-Anything-3 backbone + camera token + parallel feat DPT branch deep-copied from depth). Same factored YX×Z×T scoring as DinoVolumeScene. Defaults swap to n_height_bins=128, feat_dim=32. Saves model_kind='da3_volume_scene' in ckpt. Mutually exclusive with --per_voxel.z--hires_factorizedu   Use DinoVolumeSceneHires — DINOv3 backbone + bilinear up + 5-layer CNN at pred_size=256. Factorized scoring. Defaults: n_height_bins=128, feat_dim=48. Saves model_kind='dino_volume_scene_hires'.z--hires_per_voxelu   Use DinoVolumeScenePerVoxelHires — DINOv3 + 5-layer CNN at pred_size=256, then 1×1 conv expansion to feat_dim*n_z and reshape to per-voxel volume. Defaults: n_height_bins=64, feat_dim=16. Saves model_kind='dino_volume_per_voxel_hires'.z--hires_flatu   Use DinoVolumeSceneHiresFlat — same backbone + CNN as DinoVolumeSceneHires, but the per-T queries come from a single flat MLP output (output dim = T × per_T_dim) instead of T independent AdaLN-Zero forwards. Better temporal coherence by construction.z--volumetricuZ  Use DinoVolumeSceneVolumetric — unproject image features into a P×P×Z world-space voxel grid, concat sin/cos height encoding, 3-layer per-voxel MLP, then dot-product against per-T queries from a flat global MLP. Adds a +1 GT-voxel slot at training for precise (unquantized) supervision. Defaults: pred_size=128, n_height_bins=64, feat_dim=32.z--cls_fusionconcatprimaryzMulti-view CLS fusion mode for the grip/rot head. 'concat' (new default) concatenates every view's CLS before the global MLP; 'primary' uses only views[0]'s CLS (matches the original 2026-06-09 ckpts).z--cross_view_layerszDA3-style alternating within/cross-view self-attention blocks over the native DINO patch grid (~31x31). 0 disables. 4-5 is the sweet spot per Depth-Anything-3 (arXiv:2511.10647).z--cross_view_headsz--v4zv4 = v2 multi-view MLP fusion + sin/cos height PE + per-view adaptive z range. Uses DinoVolumeSceneV4. Keeps the same out dict shape as the v2 multiview model so multiview_losses + viz pipeline reuse unchanged. Requires --multiview.z--v4_da3zxv4 head + DA3 backbone (multi-view ViT with built-in cross-attention + camera token; NO DPT head). Requires --multiview.z--v4_vlmz{v4 head + InternVL2.5-1B vision tower (LLM frozen, vision trainable, text-conditioned via task name). Requires --multiview.z--v4_dynaflipzv4 head + DynaFLIP-base vision backbone (jlee-larr/dynaflip-base, ~0.2 B params). Per-view loop, no backbone-level cross-view fusion. Requires --multiview.z--v4_paligemmazv4 head + PaliGemma vision tower + Gemma LLM (google/paligemma-3b-pt-448 by default). Mirrors v4_vlm but with the PaliGemma stack instead of InternVL. Requires --multiview.z--v4_pi0zv4 head + pi0's PaliGemma backbone (LeRobot port lerobot/pi0_base, ~14 GB safetensors). PaliGemma weights replaced by pi0's robot-data pretrain; the flow-matching action expert is discarded. Requires --multiview.z--pi0_safetensors_pathzROptional override for the pi0_base safetensors file. Default = pull from HF cache.z--paligemma_model_namezgoogle/paligemma-3b-pt-448zHF model id for the PaliGemma variant. The 448 variant fits puget 24 GB at B=2 with grad-ckpt + frozen LLM; for unfrozen-LLM training run on yukon (96 GB).z--vlm_task_textzpick and placez,Task prompt for the VLM (e.g. dataset name).z--vlm_freeze_llmFzYDefault: train the LLM (gradient checkpointing on). --no-vlm_freeze_llm keeps LLM frozen.)r  r  r  z--cam_margin_mg{Gz?u   v4: each view's z_hi is capped at cam_z - this margin (metres). Wrist cam → adaptive small z range; scene cam → unchanged (sanity-checked to stay above global z_hi).z--v3u   v3 factorized dot-product model (DinoVolumeSceneV3). Per-pixel feature splits into [F_z|F_t|F_s] which dot-product against [PE_z|PE_t|spatial_q]. No per-voxel MLP. Factored loss never materialises the (B, T, V) volume — supports P=Z=256 cheaply.z--v3_F_zz--v3_F_tz--v3_F_sz--per_voxel_grip_rotuK  Predict grip + rot from the GT-nearest voxel feature (teacher-forced at train, argmax at infer) via a small 1D-CNN over T, instead of from the global MLP query. Same idea as production PARA's pixel-indexed heads. Default ON (2026-06-10 — Cameron made this canonical). Pass --no-per_voxel_grip_rot to fall back to the global head.z--temporal_headflat_mlptemporal_cnnu%  Per-voxel grip/rot temporal head. 'flat_mlp' (new default 2026-06-10): 4-layer dense MLP over the T·F flattened gathered features → full receptive field, implicit absolute positional info. 'temporal_cnn': 3-layer 1D conv over T — the old default; receptive field ~7 timesteps, no time PE.z--temporal_cnn_layersz61D CNN depth (only with --temporal_head temporal_cnn).z--temporal_cnn_kernelz--temporal_mlp_hiddenr   z)Hidden dim of the flat MLP temporal head.z--mv_past_nu$  (multi-view only) Past N frames of (grip, z) fed as proprio conditioning to the global query MLP. 0 disables. 8 was Cameron's 2026-06-10 default — matches frame_stride * 8 = 32 raw frames of recent EE state, enough to disambiguate 'just closed' vs 'closed for a while → ready to release'.z--mv_past_enc_dimz/Encoder output dim for the past-trajectory MLP.z--multiviewuf  Comma-separated views for the multi-view volumetric model — e.g. 'scene', 'wrist', or 'scene,wrist'. Builds one P×P×Z sub-volume per view; each voxel gets features bilinear-sampled from ALL listed views' feature maps, concatenated, then fused by a 3-layer MLP. Loss is nearest-3D-point across the full N×P×P×Z combined volume. Mutex with --volumetric.z--height_enc_dimzHVolumetric model only: sin/cos PE dim for the per-voxel height encoding.z--voxel_mlp_hiddenz2Volumetric model only: per-voxel MLP hidden width.z--refit_z_rangeu  When finetuning, ignore the source ckpt's z_range and let YamScene auto-fit a fresh range on the new dataset. Also drops ``height_emb.weight`` from the source state_dict (the bin-index → physical-Z mapping changes, so the embedding is stale). Required when the new task's EE-Z extent differs materially from the source's (e.g. table-level manipulation finetuned from a pickplace cup).z--refit_rot_centroidsa4  Used with --init_from: refit K-means rot centroids on the NEW dataset instead of inheriting from the source ckpt, AND skip loading rot_head.* weights (since their output indices map to the OLD centroid IDs). Use when the new dataset has a different rotation distribution from the source ckpt's training data.z--hires_ablatezUse DinoVolumeSceneHiresAblate (factorized hires with configurable past-encoding / MLP / backbone-fusion ablation knobs). Mutex with the other model flags.z--past_nz'Past timesteps to encode (0 = no past).z--past_z_deltaui   Encode past_z as (past_z − current_z) instead of absolute height. Pairs naturally with --past_uv_delta.z--past_use_uvu3   Concat past pixel coords (img_size px → [-1, 1]).z--past_uv_deltaz/With --past_use_uv: subtract current start_pix.z--past_use_xyzz)Concat past world XYZ (m, centered ~0.3).z--past_xyz_deltaz8With --past_use_xyz: also concat past_xyz - current_xyz.z--mlp_layersu3   Depth of the global MLP (1=plain Linear, ≥2=MLP).z--mlp_residualu9   Residual MLP (skip every block; needs --mlp_layers ≥3).z--mlp_hidden_multg       @u3   MLP hidden = d_model × this (mlp_layers > 1 only).z--backbone_layer_fusionu]   Concat DINOv3 patch tokens from layers [3,6,9,11] before feat_head (4× embed_dim per patch).)parentsexist_okr^   )map_locationweights_onlyz  finetune from z  (source step=step)dataset_cfgz_rangez[  --refit_z_range: ignoring source ckpt's z_range; auto-fitting fresh range on new dataset.rot_centroidsz`  --refit_rot_centroids: ignoring source ckpt's rot_centroids; refitting K-means on new dataset.)rootn_windowframe_strider   r   r   n_gripper_binsn_rot_clustersr"  
grip_ranger#  past_nc                  <a  / pR F1  p\         P                  ! S  Uu. uF  q3V,          NK  	  up4      W&   K3  	  S  Uu. uF  q3R,          NK  	  upVR&   RS ^ ,          9   d   S  Uu. uF  q3R,          NK  	  upVR&   R FA  pVS ^ ,          9   g   K  \         P                  ! S  Uu. uF  q3V,          NK  	  up4      W&   KC  	  \        ;QJ d    V 3R lS 4       F  '       d   K   RM	  RM! V 3R lS 4       4      '       d8   S F1  p\         P                  ! S  Uu. uF  q3V,          NK  	  up4      W&   K3  	  V# u upi u upi u upi u upi u upi )rgbr8   r9   c              3  :   <"   T F  qS^ ,          9   x  K  	  R# 5i)    Nr   ).0r   r   s   & r   	<genexpr>)main.<locals>._collate.<locals>.<genexpr>  s     1jE!H}js   FT)r,  	start_pixr   r   r;   r<   )r:   r=   r>   	wrist_rgbr?   r@   )r   r   all)r   rx   r   r   
_past_keyss   f   r   _collatemain.<locals>._collate  s&   /A[[!61A$$!67CF/ 388%QZ==%8JuQx'BG$H%Q'7%8%8%$HC !;AE!H}E%:EqddE%:;; 31j13331j111E%:EqddE%:;  
 "78$H &; &;s   E 
 E)E
)E
 E
)
batch_sizeshufflenum_workers
pin_memory	drop_last
collate_fnz--da3 / --per_voxel / --hires_factorized / --hires_per_voxel / --hires_ablate / --hires_flat / --volumetric / --multiview are mutually exclusive,)DA3VolumeScene)DinoVolumeSceneHires)DinoVolumeScenePerVoxelHires)DinoVolumeSceneHiresAblate)DinoVolumeSceneHiresFlat)DinoVolumeSceneVolumetricz(--v4_da3 requires --multiview to be set.)DinoVolumeSceneV4DA3z(--v4_vlm requires --multiview to be set.)DinoVolumeSceneV4VLMz---v4_dynaflip requires --multiview to be set.)DinoVolumeSceneV4DynaFLIPz.--v4_paligemma requires --multiview to be set.)DinoVolumeSceneV4PaliGemmaz(--v4_pi0 requires --multiview to be set.)DinoVolumeSceneV4Pi0z$--v4 requires --multiview to be set.)DinoVolumeSceneV4z$--v3 requires --multiview to be set.)DinoVolumeSceneV3)"DinoVolumeSceneVolumetricMultiView)r%  n_height_binsr   feat_dimheight_enc_dimvoxel_mlp_hiddend_model
mlp_layersmlp_hidden_multr'  r(  r   r   r   r2   r%  rM  r   rN  rO  rP  rQ  rR  rS  r'  r(  r   r   r   
cls_fusioncross_view_layerscross_view_headsper_voxel_grip_rottemporal_headtemporal_cnn_layerstemporal_cnn_kerneltemporal_mlp_hiddenr*  past_enc_dimcam_margin_mtask_text_default
freeze_llmpaligemma_model_namepi0_safetensors_pathF_zF_tF_s)	r%  rM  r   rN  rQ  n_blocks
mlp_hiddenr'  r(  )r   r*  past_z_deltapast_use_uvpast_uv_deltapast_use_xyzpast_xyz_deltarR  mlp_residualrS  backbone_layer_fusionz
  model = z (feat_dim=z, n_height_bins=modelz	rot_head.z!  --refit_rot_centroids: dropped z< rot_head keys from source ckpt (keeping fresh random init).c              3  `   <"   T F#  pSV8H  ;'       g    SP                  V4      x  K%  	  R # 5iN
startswith)r/  pr   s   & r   r0  main.<locals>.<genexpr>  s(      RMqa!:!:1<<?!:Ms   ..z  --refit_z_range: dropped z z-axis keys from source ckpt (u   ); bin-index → physical-Z mapping changed, keeping fresh random init for height_emb and the model's freshly-computed bin_centers_z buffer.z  shape-skip z3 keys (n_window or n_height_bins probably changed)::N   Nz    z: src u	    → dst )strictz   load_state_dict missing keys: z#  load_state_dict unexpected keys: z  loaded model weights from c              3  F   <"   T F  pSP                  V4      x  K  	  R # 5irp  rq  )r/  prens   & r   r0  rt    s     "M1<<#4#4s   !z  param groups: head=z (z.1eu   →z) backbone=z	) warmup=z
 schedule=paramslrnameheadlr_maxlr_minbackbonec               (    V ^8  d   QhRRRRRRRR/# )r   itr   r~  r   r  returnr   )r   s   "r   r   main.<locals>.__annotate__  s(      3  u  r   c                  < SP                   ^ 8  d2   V SP                   8  d!   W^,           ,          SP                   ,          # SP                  R8X  d   \        ^SP                  SP                   ,
          4      p\	        R\        RV SP                   ,
          V,          4      4      pVRW,
          ,          R\
        P                  ! \
        P                  V,          4      ,           ,          ,           # V# )r.  r  r          r   )	lr_warmuplr_scheduler   	max_itersrb   mathcospi)r  r~  r  denomprogressargss   &&&  r   _lr_atmain.<locals>._lr_at  s    >>A"t~~"5!V$t~~55x'4>>DNN:;E3C"t~~*=)F GHHC6?3sTXXdggPXFX=Y7YZZZr   )projectr|  configzwandb: z
(disabled)u
   ckpts → c                  < SP                   '       d   RV 9  d   / # RV R,          P                  SP                  RR7      RV R,          P                  SP                  RR7      RV R,          P                  SP                  RR7      RV R,          P                  SP                  RR7      RV R,          P                  SP                  RR7      /# )uz   Build past-feature kwargs for model.forward() — empty dict if
--hires_ablate isn't set or no past keys are in the batch.past_zTnon_blocking	past_grippast_uvpast_xyzcurrent_xyz)hires_ablatetodevicerw   r  s   &r   _past_kwmain.<locals>._past_kw'  s        HE$9IeHo((4(H{+..t{{.NuY'**4;;T*Jj),,T[[t,L5/224;;T2R
 	
r   c                    V ^8  d   QhRRRR/# )r   rw   dictr  r   )r   s   "r   r   r  4  s     
 
d 
t 
r   c                   < SP                   '       g   / # RV R,          P                  SP                  RR7      P                  4       RV R,          P                  SP                  RR7      P                  4       /# )z9K_in, T_w2c kwargs the volumetric model needs at forward.K_inr=   Tr  r   r>   )
volumetricr  r  r   r  s   &r   _volumetric_kwmain.<locals>._volumetric_kw4  sg    IE'N%%dkk%EKKMU8_''$'GMMO
 	
r   )volumetric_lossesc           
       < . p. p. pS EF  pVR8X  d   VP                  VR,          P                  SP                  RR7      P                  4       4       VP                  VR,          P                  SP                  RR7      P                  4       4       VP                  VR,          P                  SP                  RR7      P                  4       4       K  VR8X  d   VP                  VR,          P                  SP                  RR7      P                  4       4       VP                  VR	,          P                  SP                  RR7      P                  4       4       VP                  VR
,          P                  SP                  RR7      P                  4       4       EK  \	        RV: 24      h	  VR,          P                  SP                  RR7      P                  4       pSP
                  ;'       g    SP                  pV'       d3   VR,          P                  SP                  RR7      P                  4       MRpR;rSP                  ^ 8  de   VR,          P                  SP                  RR7      P                  4       p	VR,          P                  SP                  RR7      P                  4       p
SP
                  '       d   V ! W#WHWR7      # V ! W&W4VWR7      # )zyForward call for the multi-view volumetric model. Builds the
(rgb, K, T_w2c) lists in `multi_views` order from the batch.rA   r,  Tr  r=   r>   rD   r3  r?   r@   zunknown view: r2  r:   Nr  r  )r  r   r:   r  r  )rc   r  r  r   
ValueErrorv3rW  	mv_past_n)rn  rw   rgb_listK_listT_listr~   spwant_tgttgtr  r  r  multi_viewss   &&         r   _multiview_callmain.<locals>._multiview_callB  sX    AG|e$ O U U WXeGn//$/OUUWXeHo0040PVVXYgk 2 5 5dkkPT 5 U [ [ ]^eJ/224;;T2RXXZ[eN366t{{QU6V\\^_ >!!788  ;""4;;T"BHHJ 7755d55 \"%%dkk%EKKM!% 	 "!	>>Ak*--dkk-MSSUI8_''$'GMMOF777f$-> >X ): 	:r   )	v3_losses)multiview_lossesr,  r  r2  )r   r   r   r   )r  z+  step 0 viz logged (pre-training baseline)r   r   r;   r<   r:   )set_to_nonez
loss/totaliterit_per_szlr/groupzlatest.pth.tmpoptr  
model_kinddino_volume_scene_v4_da3dino_volume_scene_v4_vlmdino_volume_scene_v4_dynaflipdino_volume_scene_v4_paligemmadino_volume_scene_v4_pi0dino_volume_scene_v4dino_volume_scene_v3da3_volume_scenedino_volume_scene_hires_ablatedino_volume_scene_hires_flatdino_volume_scene_hiresdino_volume_per_voxel_hiresdino_volume_per_voxel&dino_volume_scene_volumetric_multiviewdino_volume_scene_volumetricdino_volume_scenez
latest.pthz	  ckpt @ z  total=z.4fz vol=zloss/volumez grip=z	loss/gripz rot=zloss/rotz  z.2fz it/s)flushgɿ)r  r  r  r  r  r   )zheight_emb.bin_centers_z)z	backbone.z	dynaflip.zvlm.)argparseArgumentParseradd_argumentstrr   homer   r   BooleanOptionalAction
parse_args	ckpt_rootr|  mkdir	init_fromr   loadprintrefit_z_ranger   r   refit_rot_centroidsr   	data_rootr%  r&  r   r   rM  r'  r(  grip_logrip_hir  r*  	multiviewr  r  r   r8  r:  r   da3r   hires_factorizedhires_per_voxel
hires_flatr  r   r  splitlib.model_da3r?  lib.model_hiresr@  rA  rB  rC  lib.model_volumetricrD  v4_da3lib.model_volumetric_v4_da3rE  v4_vlmlib.model_volumetric_v4_vlmrF  v4_dynaflip lib.model_volumetric_v4_dynafliprG  v4_paligemma!lib.model_volumetric_v4_paligemmarH  v4_pi0lib.model_volumetric_v4_pi0rI  v4lib.model_volumetric_v4rJ  r  r   rK  lib.model_volumetric_multiviewrL  r   r   rN  v3_F_zv3_F_tv3_F_sr  rO  rP  rQ  rR  rS  rT  rU  rV  rW  rX  rY  rZ  r[  mv_past_enc_dimr]  vlm_task_textvlm_freeze_llmr`  ra  re  rf  updaterg  rh  ri  rj  rk  rl  rm  r  r  __name__rr  r   rj   any
state_dictr%   rc   r   load_state_dictnamed_parametersrequires_gradid
parametersr{  r  backbone_lr_multr  r  optimAdamWru   initwandb_projectvarsrunurlr  r  r  no_gradnextr  r   r	  timeperf_counterr  param_groupsr   	zero_gradbackwardr  r`   itemvis_every_itersckpt_every_iterssavereplace)Rrs  ckpt_dirinit_cksrc_zz_range_argrot_c_from_srcdsr!  r6  loadermutex_flagsr?  	model_clsr@  rA  rB  rC  rD  rE  rF  rG  rH  rI  rJ  rK  rL  model_feat_dimmodel_kwargsrn  src_sdr   droppedr~   drop_prefixes	dropped_zmodel_sdshape_skippedfiltered_sd	src_shape	dst_shapemissing
unexpected_BB_PREFIXESry  backbone_paramsbb_idshead_paramshead_lr_maxhead_lr_min	bb_lr_max	bb_lr_minr  r  r  r  _vol_lossesr  
_mv_lossespeekrgb0sp0out0r  t_looprw   r,  r  tgt_yxtgt_ztgt_gtgt_rpgrx   tgt_xyzlossesnowitsr   tmpr5  r  r  sR                                 `            `                                   @@@r   mainrJ    s   !ANN8dN+NN=4N0NN=#diik<R.R*SNTNN$.@NANN>RN8NN?a3  4 NN6tM  ONN:E4U  V NN'eSE  F NN=sAQ  R NN?J&1V  X NN<c2N6NN##qN9NN$3N;NN%CN<NN%CN=NN=sCN8NN<c3N7NN<c2N6NN;S#N6NN<c1N5NN>SN9NN8%A  B NN8%4  5 NN;UDN9NN;UCN8NN=sDL  M NN'c3N?NN&S"N=NN:vN.NN=$J  K NN=T  U NN7<?  @ NN'F  G
 NN&|J  K NN>,O  P NN>,H  I NN>8h	=RG  H
 NN(sAY  Z NN'c1N=NN6,N  O NN:l7  8 NN:l0  1 NN?<0  1
 NN#L:  ;
 NN:l0  1 NN+T>  ? NN+7#  $ NN$.>F  HNN%h.L.L @  A NN#%3  4
 NN6,4  5 NN:CN4NN:CN4NN:CN4NN)(2P2PX  Y NN$j&7M  N NN*aP  RNN*aN@NN*cC  ENN=sAE  F NN&S"I  KNN=$O  P NN%C5  6 NN'c2L  NNN$\T  U NN*<@  A NN#LM  N NN:CA  CNN#LQ  R NN?<M  ONN$\I  KNN#LC  ENN%lR  TNN>QM  ONN#LS  UNN&UCM  ONN,\F  G <<>DDNN#dii/HNN4$N/
 G~~~**T^^%eT  0 1%fo.a1 	2 !!!M*95E#(q?E%(O DIty = >
 		-$))2G IItyy)  (@(@(@ 	/  G$7 2 	3	$..!T->->..4==t/B/B**t||(D$#000'+~~~T^^
B 77BGGDIty))+KNJ( t%)%5%5$#'H>F txx,,d.B.B(($//T^^(<> ?K Q M N 	N 154>>'',DKxxx0"					8(					@0					>.		<,		B-		FFF{D(		FFF{D(					KKK{N-					LLL{P.		FFF{D(		BBB{=%		BBB{=%		U6		+	#	 xxxDMMR'				$--2"5	DMMR/	T]]b0	T]]b(t{{2T[[@	","DM]],,nn#..!22LL 00....]]
 
t'7'7'74;L;L;L  

]]
 ,,
 nn	

 $
  ..
 "22
 LL
 
 !00
  ..
  ..
 ]]
 
 "&
 
  #44!
" "22#
$  $66%
& ,,'
( !% 8 8)
* !% 8 8+
, !% 8 8-
. >>/
0 --1
2 **3
6 ;;;040B0BL,-)-)<)<L&373L3LL/0040B0BL,-)-)<)<L&;;;373L3LL/0040B0BL,-)-)<)<L&((47;7P7P34	  

]]
 ,,
 nn	

 $
  ..
 "22
 LL
 
 !00
  ..
  ..
 ]]
 
 "&
 
  #44!
" "22#
$  $66%
& ,,'
( !% 8 8)
* !% 8 8+
, !% 8 8-
. >>/
0 --1
2 **3
6 
 

]]
 ,,
 nn	

 LL
 
 !00
  ..
  ..
 ]]
 
 "&
 
 
 
 >>
  --!
$ 
 

]]
 ,,
 nn	

 $
  ..
 "22
 LL
 
 !00
  ..
  ..
 ]]
 
 "&
 
  #44!
" "22#
$  $66%
& ,,'
( !% 8 8)
* !% 8 8+
, !% 8 8-
. >>/
0 --1
6 ]]$2D2Dnn~LL4==....
 ]];;**((,,**..** 00"&"<"< 	 	
 %%((5E	Jy))*+n5E F--.a1 2!###"(F&QALL,Eqq&GF'-||~W~tq!Q\\+=Vdad~FW5c'l^ DG G H
 =M$* TFq S RM RSSS RM RR FI T'-||~L~tq!)9Kdad~FL/I/? @''0k 2KK L ##%LLNDAqH}!!2!2agg!=$$aqwwx{?P?P9Q%RS!"A	 #
 M#m"4!5 65 5 6+8+<+<'9iQCvi[	)EF ,=#33K3N43334WR[MBC7
27GHI,T^^,<=> 6L,,..da?? 	
"s"M"Msss"M"MM 	
.   --_be_F-#..0 ?0oo *,Q%v*= 10K ?''K!%!8$++dggK$///Id333I	!#k"2!32k#5Fc+VYIZ [/*+2i_C	# ONN#:d.>.>-?A B ++

	;D+vv	;+	7	?D)vz	9)	5 C  
JJt))		$t*M	GUYYYEIIMMLA
BC	Jxj
!"

 
 I :D wwwC	Q
 
DL!E{~~dkk~=;""4;;T"B"5$/DsMhtnMt8LMD		*T4$--'+~~'`'`9M9M'`'`QUQ`Q`hlhqhqx|  yB  yBC JK	L;< 
 D F

E,//$++D/AC{#&&t{{&FB;'**4;;T*JF*%((4(HE-(++DKKd+KE,'**4;;T*JE&&!$8blC4 '%eU3-0040PVVX777'WeUCF'VUE5'RFCPxP.:OP*#L144T[[t4TZZ\G(feUE7SF'VUE5IFMMdM+< ))+HHJAID##%Cv&CF4S1C&&79$xc"&&1234 '((+D1CI1A 'd***a/

:eS4==26..2k2kDDXDX2k2k\`\k\k,0IIDIIG H IIc%d+++q0!11

U--/3>>+DDJ!; 6:kkk2;?;;;7@D@P@P@P<AEARARAR=;?;;;77;www37;www337888/AEARARAR=?C;:>:O:O:O6>B>R>R>R:8<4IME?C;0-. /0 H|34	$x|0D0I0I0KC/P Q#M2779#> ?$[1668= >#J/446s;2c#YeM !	" t~~%]   S GWTLP .?D 
s   V$BJWBJWBJ!W>BJ!X:BJ'Y
BJ'Y!BJ'ZBJ'ZBJ,Z-BJ,aBJ2a,
BJ2a7BJ2bBJ2b0BJ2b=BJ8c'BJ=dBJ=dBJ=l=CBKpBKp<BKKBK	__main__)   Fr  r   )-__doc__
__future__r   r  r  sysr  pathlibr   rd   r_   r#   r   ru   torch.utils.datar   pathinsertr  __file__resolveparentlib.dataset_arviewr   	lib.modelr   r   r   lib.viz.bin_gridsr	   lib.viz.feature_pcar
   r   lib.viz.heatmapr   lib.viz.height_curver   lib.viz.keypointsr   r-   r   r   r	  rJ  r  r   r   r   <module>r^     s   * #   
   
    ' 3tH~--/667 8 * J J , L 1 3 /
aHcLNbsl zF r   