diffneusim 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- diffneusim/__init__.py +1 -0
- diffneusim/_cache.py +42 -0
- diffneusim/_paths.py +5 -0
- diffneusim/bindings/rew14_ext.cu +115 -0
- diffneusim/bindings/soft14_capi.cpp +443 -0
- diffneusim/bindings/soft14_engine_ext.cu +596 -0
- diffneusim/bindings/soft_capi.cpp +782 -0
- diffneusim/bindings/soft_engine_ext.cu +495 -0
- diffneusim/core/cpu_engine/build.sh +40 -0
- diffneusim/core/cpu_engine/fiber/cuda_runtime.h +445 -0
- diffneusim/core/cpu_engine/x14_cpu.cpp +283 -0
- diffneusim/core/diff/dual.h +126 -0
- diffneusim/core/include/diffneusim/macros.h +35 -0
- diffneusim/core/kin/kinematic_tree.h +273 -0
- diffneusim/core/math/so3.h +182 -0
- diffneusim/core/soft/adj/out_adj.h +102 -0
- diffneusim/core/soft/adj/rnea_adj.h +425 -0
- diffneusim/core/soft/adj/rows_adj.h +439 -0
- diffneusim/core/soft/adj/rows_functor.h +89 -0
- diffneusim/core/soft/adj/rows_lanes.h +443 -0
- diffneusim/core/soft/adj/shell_adj.h +243 -0
- diffneusim/core/soft/adj/tree_adj.h +356 -0
- diffneusim/core/soft/collide.h +183 -0
- diffneusim/core/soft/gpu/adj14.cuh +233 -0
- diffneusim/core/soft/gpu/adj14_mus.cuh +98 -0
- diffneusim/core/soft/gpu/adj_shell.cuh +50 -0
- diffneusim/core/soft/gpu/adj_tab.cuh +49 -0
- diffneusim/core/soft/gpu/body14.cuh +47 -0
- diffneusim/core/soft/gpu/chol_rn.cuh +458 -0
- diffneusim/core/soft/gpu/chol_small.cuh +123 -0
- diffneusim/core/soft/gpu/chol_split.cuh +193 -0
- diffneusim/core/soft/gpu/engine_launch.cuh +263 -0
- diffneusim/core/soft/gpu/fk_rn.cuh +109 -0
- diffneusim/core/soft/gpu/generated/body_019e20820f86_mmfloor.cuh +28 -0
- diffneusim/core/soft/gpu/generated/body_62f77a4bb16b_mmfloor.cuh +52 -0
- diffneusim/core/soft/gpu/generated/body_77dbb7213f26_mmfloor_rampsb3l_n6t12.cuh +28 -0
- diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rampsb3l_n6t12.cuh +28 -0
- diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rhlsd05_n6t12.cuh +28 -0
- diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rhlsdef_n6t12.cuh +28 -0
- diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rhlsmjd_n6t12.cuh +28 -0
- diffneusim/core/soft/gpu/generated/body_a1e8b196b2cd_mmfloor_rampsb3l_n6t12.cuh +52 -0
- diffneusim/core/soft/gpu/generated/body_a944653edd64_mmfloor.cuh +25 -0
- diffneusim/core/soft/gpu/generated/body_a944653edd64_mmfloor_rampsb3l_n6t12.cuh +25 -0
- diffneusim/core/soft/gpu/generated/g1_soft_5db44fd45286.cuh +74 -0
- diffneusim/core/soft/gpu/generated/split_62f77a4bb16b_mmfloor.cuh +18 -0
- diffneusim/core/soft/gpu/generated/split_a1e8b196b2cd_mmfloor_rampsb3l_n6t12.cuh +18 -0
- diffneusim/core/soft/gpu/generated/x14_soft_019e20820f86_mmfloor.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_62f77a4bb16b_mmfloor.cuh +129 -0
- diffneusim/core/soft/gpu/generated/x14_soft_77dbb7213f26_mmfloor_rampsb3l_n6t12.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rampsb3l_n6t12.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rhlsd05_n6t12.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rhlsdef_n6t12.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rhlsmjd_n6t12.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_a1e8b196b2cd_mmfloor_rampsb3l_n6t12.cuh +129 -0
- diffneusim/core/soft/gpu/generated/x14_soft_a944653edd64_mmfloor.cuh +123 -0
- diffneusim/core/soft/gpu/generated/x14_soft_a944653edd64_mmfloor_rampsb3l_n6t12.cuh +123 -0
- diffneusim/core/soft/gpu/k_mus.cuh +1038 -0
- diffneusim/core/soft/gpu/k_mus_host.cuh +377 -0
- diffneusim/core/soft/gpu/k_pre.cuh +52 -0
- diffneusim/core/soft/gpu/kernel_p.cuh +490 -0
- diffneusim/core/soft/gpu/kp14.cuh +465 -0
- diffneusim/core/soft/gpu/l2v2.cuh +367 -0
- diffneusim/core/soft/gpu/l2x14.cuh +319 -0
- diffneusim/core/soft/gpu/l3.cuh +1483 -0
- diffneusim/core/soft/gpu/model_view.cuh +48 -0
- diffneusim/core/soft/gpu/mus_case_fits.h +15 -0
- diffneusim/core/soft/gpu/mus_classes.h +182 -0
- diffneusim/core/soft/gpu/mus_row_cf.h +44 -0
- diffneusim/core/soft/gpu/rew14.cuh +177 -0
- diffneusim/core/soft/gpu/rows_ctab.cuh +44 -0
- diffneusim/core/soft/gpu/tree_m.cuh +247 -0
- diffneusim/core/soft/gpu/x14_engine_kernels.cuh +260 -0
- diffneusim/core/soft/gpu/x14_rowcf.h +14 -0
- diffneusim/core/soft/hand.h +124 -0
- diffneusim/core/soft/impedance.h +115 -0
- diffneusim/core/soft/jvp.h +202 -0
- diffneusim/core/soft/kin.h +250 -0
- diffneusim/core/soft/muscle.h +1208 -0
- diffneusim/core/soft/newton.h +371 -0
- diffneusim/core/soft/rows.h +176 -0
- diffneusim/core/soft/step.h +188 -0
- diffneusim/core/soft/tape.h +313 -0
- diffneusim/core/soft/x14/collide14.h +69 -0
- diffneusim/core/soft/x14/jvp14.h +182 -0
- diffneusim/core/soft/x14/law14.h +453 -0
- diffneusim/core/soft/x14adj/collide14_adj.h +134 -0
- diffneusim/core/soft/x14adj/passive14_adj.h +162 -0
- diffneusim/core/soft/x14adj/reward14.h +484 -0
- diffneusim/core/soft/x14adj/rows14_adj.h +400 -0
- diffneusim/core/soft/x14adj/scan14.h +349 -0
- diffneusim/core/soft/x14adj/shell14_adj.h +122 -0
- diffneusim/core/soft/x14adj/sweep14.h +255 -0
- diffneusim/core/soft/x14adj/tree14_adj.h +500 -0
- diffneusim/core/soft/x14adj/x14adj_common.h +96 -0
- diffneusim/data/mirror/H1622v2k_geyer_hfdeq.npz +0 -0
- diffneusim/data/mirror/H1622v2k_hfd.npz +0 -0
- diffneusim/data/mirror/H1622v2k_millard_hfdeq.npz +0 -0
- diffneusim/data/mirror/fullbody_contact.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_p2str.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_p2str_rigid.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_calf2_pe.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_axfix.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_axfixlegs01.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_jd01.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_jd01legs.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_jd01lumbar.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_lumbfix.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_lumbfixlegs01.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1a.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n2.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_rom23.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_hinge.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1a.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n2.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_rom23.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_lspine_girdle_osimeq.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_lspine_girdle_millard.npz +0 -0
- diffneusim/data/mirror/fullbody_contact_spinecoupled_lspine_girdle_osimeq.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_compound_g14eq.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30_hip30.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30_hip30_luispe.npz +0 -0
- diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30_hip30_trunk0701.npz +0 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_axfix.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_axfixlegs01.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_jd01.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_jd01legs.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_jd01lumbar.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_lumbfix.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_lumbfixlegs01.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_n1.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_n1a.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_n2.json +91 -0
- diffneusim/data/muscle_fit/wang_mass_volume_14t_rom23.json +91 -0
- diffneusim/data/reference/musclemimic/myofullbody_mimic_sites.json +261 -0
- diffneusim/data/reference/pose3/pose3_scone.json +305 -0
- diffneusim/data/reference/pose3/pose3_scone.txt +3 -0
- diffneusim/data/reference/pose3/pose3_scone_gait.npz +0 -0
- diffneusim/data/reference/pose3/pose3_scone_mirror.npz +0 -0
- diffneusim/data/reference/pose3/pose3_scone_stand.npz +0 -0
- diffneusim/data/reference/x016run/MD5SUMS +241 -0
- diffneusim/data/reference/x016run/x016run_states.txt +240 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s0_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s1_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s2_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s3_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s4_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s5_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s6_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p00_s7_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s0_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s1_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s2_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s3_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s4_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s5_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s6_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p25_s7_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s0_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s1_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s2_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s3_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s5_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s6_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p50_s7_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s0_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s1_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s2_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s3_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s5_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s6_r3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_l0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_l1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_l2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_l3.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_r0.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_r1.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_r2.npz +0 -0
- diffneusim/data/reference/x016run/x016run_v3p75_s7_r3.npz +0 -0
- diffneusim/data/state_prior/lumbar_poly_fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc.npz +0 -0
- diffneusim/engine/__init__.py +0 -0
- diffneusim/engine/build_tag.py +52 -0
- diffneusim/engine/case_tables.py +46 -0
- diffneusim/engine/d16_body.py +80 -0
- diffneusim/engine/engine14.py +367 -0
- diffneusim/engine/gen_split.py +159 -0
- diffneusim/engine/hand_format.py +69 -0
- diffneusim/engine/live14.py +149 -0
- diffneusim/engine/phase_b_tree.py +137 -0
- diffneusim/engine/soft14.py +130 -0
- diffneusim/engine/soft_capi.py +373 -0
- diffneusim/engine/soft_engine.py +165 -0
- diffneusim/engine/step14.py +132 -0
- diffneusim/engine/tape_format.py +89 -0
- diffneusim/engine/x14cpu.py +163 -0
- diffneusim/env/__init__.py +0 -0
- diffneusim/env/absent.py +20 -0
- diffneusim/env/cpu14.py +105 -0
- diffneusim/env/e0loop14.py +224 -0
- diffneusim/env/env14.py +568 -0
- diffneusim/env/kin_contact14.py +193 -0
- diffneusim/env/mimic_sites_x14.json +366 -0
- diffneusim/env/old_count.py +78 -0
- diffneusim/env/rew14.py +114 -0
- diffneusim/env/rew14_hook.py +105 -0
- diffneusim/g1/__init__.py +1 -0
- diffneusim/g1/arm_a2.py +165 -0
- diffneusim/g1/arm_a3.py +576 -0
- diffneusim/g1/read_a3.py +79 -0
- diffneusim/g1/rg1_read.py +89 -0
- diffneusim/model/__init__.py +66 -0
- diffneusim/model/case.py +17 -0
- diffneusim/model/dnmodel.py +79 -0
- diffneusim/model/fuse_fixed.py +281 -0
- diffneusim/model/monitor.py +834 -0
- diffneusim/models/BODIES.toml +48 -0
- diffneusim/models/MANIFEST.toml +979 -0
- diffneusim/models/cases/G290/case.bin +0 -0
- diffneusim/models/cases/G290/case.json +1 -0
- diffneusim/models/cases/G356-SRC/case.bin +0 -0
- diffneusim/models/cases/G356-SRC/case.json +1 -0
- diffneusim/models/cases/G416/case.bin +0 -0
- diffneusim/models/cases/G416/case.json +1 -0
- diffneusim/models/cases/M290C-SRC/case.bin +0 -0
- diffneusim/models/cases/M290C-SRC/case.json +1 -0
- diffneusim/models/cases/M290R-SRC/case.bin +0 -0
- diffneusim/models/cases/M290R-SRC/case.json +1 -0
- diffneusim/models/cases/M356C-SRC/case.bin +0 -0
- diffneusim/models/cases/M356C-SRC/case.json +1 -0
- diffneusim/models/cases/M356R-SRC/case.bin +0 -0
- diffneusim/models/cases/M356R-SRC/case.json +1 -0
- diffneusim/models/cases/M416C-SRC/case.bin +0 -0
- diffneusim/models/cases/M416C-SRC/case.json +1 -0
- diffneusim/models/derived/d16_expanded_62f77a4bb16b1e67_mmfloor.xml +673 -0
- diffneusim/models/derived/d16_expanded_a1e8b196b2cd7b3c_mmfloor.xml +673 -0
- diffneusim/models/derived/d16_soft_law_019e20820f8633b9_mmfloor.json +7844 -0
- diffneusim/models/derived/d16_soft_law_62f77a4bb16b1e67_mmfloor.json +16855 -0
- diffneusim/models/derived/d16_soft_law_77dbb7213f26e821_mmfloor_rampsb3l_n6t12.json +7883 -0
- diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rampsb3l_n6t12.json +7883 -0
- diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rhlsd05_n6t12.json +7868 -0
- diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rhlsdef_n6t12.json +7868 -0
- diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rhlsmjd_n6t12.json +7868 -0
- diffneusim/models/derived/d16_soft_law_a1e8b196b2cd7b3c_mmfloor_rampsb3l_n6t12.json +16894 -0
- diffneusim/models/derived/d16_soft_law_a944653edd642082_mmfloor.json +12655 -0
- diffneusim/models/derived/d16_soft_law_a944653edd642082_mmfloor_rampsb3l_n6t12.json +12700 -0
- diffneusim/models/derived/unitree_g1_soft_law.json +15580 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.dnmodel +28913 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid.dnmodel +29202 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_axfixlegs01.dnmodel +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.dnmodel +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.dnmodel +46970 -0
- diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.dnmodel +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.dnmodel +38570 -0
- diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid.dnmodel +38923 -0
- diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid_qk.txt +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.dnmodel +1 -0
- diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1_qk.txt +1 -0
- diffneusim/models/fullbody_meshes/1mc.stl +0 -0
- diffneusim/models/fullbody_meshes/2distph.stl +0 -0
- diffneusim/models/fullbody_meshes/2mc.stl +0 -0
- diffneusim/models/fullbody_meshes/2midph.stl +0 -0
- diffneusim/models/fullbody_meshes/2proxph.stl +0 -0
- diffneusim/models/fullbody_meshes/3distph.stl +0 -0
- diffneusim/models/fullbody_meshes/3mc.stl +0 -0
- diffneusim/models/fullbody_meshes/3midph.stl +0 -0
- diffneusim/models/fullbody_meshes/3proxph.stl +0 -0
- diffneusim/models/fullbody_meshes/4distph.stl +0 -0
- diffneusim/models/fullbody_meshes/4mc.stl +0 -0
- diffneusim/models/fullbody_meshes/4midph.stl +0 -0
- diffneusim/models/fullbody_meshes/4proxph.stl +0 -0
- diffneusim/models/fullbody_meshes/5distph.stl +0 -0
- diffneusim/models/fullbody_meshes/5mc.stl +0 -0
- diffneusim/models/fullbody_meshes/5midph.stl +0 -0
- diffneusim/models/fullbody_meshes/5proxph.stl +0 -0
- diffneusim/models/fullbody_meshes/NOTICE +2 -0
- diffneusim/models/fullbody_meshes/capitate.stl +0 -0
- diffneusim/models/fullbody_meshes/clavicle.stl +0 -0
- diffneusim/models/fullbody_meshes/hamate.stl +0 -0
- diffneusim/models/fullbody_meshes/hat_cervical.stl +0 -0
- diffneusim/models/fullbody_meshes/hat_jaw.stl +0 -0
- diffneusim/models/fullbody_meshes/hat_skull.stl +0 -0
- diffneusim/models/fullbody_meshes/humerus.stl +0 -0
- diffneusim/models/fullbody_meshes/l_bofoot.stl +0 -0
- diffneusim/models/fullbody_meshes/l_femur.stl +0 -0
- diffneusim/models/fullbody_meshes/l_fibula.stl +0 -0
- diffneusim/models/fullbody_meshes/l_foot.stl +0 -0
- diffneusim/models/fullbody_meshes/l_patella.stl +0 -0
- diffneusim/models/fullbody_meshes/l_pelvis.stl +0 -0
- diffneusim/models/fullbody_meshes/l_talus.stl +0 -0
- diffneusim/models/fullbody_meshes/l_tibia.stl +0 -0
- diffneusim/models/fullbody_meshes/lumbar1.stl +0 -0
- diffneusim/models/fullbody_meshes/lumbar2.stl +0 -0
- diffneusim/models/fullbody_meshes/lumbar3.stl +0 -0
- diffneusim/models/fullbody_meshes/lumbar4.stl +0 -0
- diffneusim/models/fullbody_meshes/lumbar5.stl +0 -0
- diffneusim/models/fullbody_meshes/lunate.stl +0 -0
- diffneusim/models/fullbody_meshes/pisiform.stl +0 -0
- diffneusim/models/fullbody_meshes/r_bofoot.stl +0 -0
- diffneusim/models/fullbody_meshes/r_femur.stl +0 -0
- diffneusim/models/fullbody_meshes/r_fibula.stl +0 -0
- diffneusim/models/fullbody_meshes/r_foot.stl +0 -0
- diffneusim/models/fullbody_meshes/r_patella.stl +0 -0
- diffneusim/models/fullbody_meshes/r_pelvis.stl +0 -0
- diffneusim/models/fullbody_meshes/r_talus.stl +0 -0
- diffneusim/models/fullbody_meshes/r_tibia.stl +0 -0
- diffneusim/models/fullbody_meshes/radius.stl +0 -0
- diffneusim/models/fullbody_meshes/sacrum.stl +0 -0
- diffneusim/models/fullbody_meshes/scaphoid.stl +0 -0
- diffneusim/models/fullbody_meshes/scapula.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic10_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic11_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic12_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic1_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic2_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic3_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic4_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic5_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic6_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic7_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic8_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thoracic9_s.stl +0 -0
- diffneusim/models/fullbody_meshes/thorax.stl +0 -0
- diffneusim/models/fullbody_meshes/thumbdist.stl +0 -0
- diffneusim/models/fullbody_meshes/thumbprox.stl +0 -0
- diffneusim/models/fullbody_meshes/trapezium.stl +0 -0
- diffneusim/models/fullbody_meshes/trapezoid.stl +0 -0
- diffneusim/models/fullbody_meshes/triquetrum.stl +0 -0
- diffneusim/models/fullbody_meshes/ulna.stl +0 -0
- diffneusim/models/source/myo_fullbody/UPSTREAM.md +91 -0
- diffneusim/models/source/myoleg/UPSTREAM.md +52 -0
- diffneusim/models/source/unitree_g1/LICENSE.mjlab +202 -0
- diffneusim/models/source/unitree_g1/UPSTREAM.md +38 -0
- diffneusim/models/source/unitree_g1/assets/head_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_ankle_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_ankle_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_elbow_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_hip_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_hip_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_hip_yaw_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_knee_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_rubber_hand.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_shoulder_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_shoulder_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_shoulder_yaw_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_wrist_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_wrist_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/left_wrist_yaw_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/logo_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/pelvis.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/pelvis_contour_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_ankle_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_ankle_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_elbow_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_hip_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_hip_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_hip_yaw_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_knee_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_rubber_hand.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_shoulder_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_shoulder_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_shoulder_yaw_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_wrist_pitch_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_wrist_roll_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/right_wrist_yaw_link.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/torso_link_rev_1_0.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/waist_roll_link_rev_1_0.STL +0 -0
- diffneusim/models/source/unitree_g1/assets/waist_yaw_link_rev_1_0.STL +0 -0
- diffneusim/models/source/unitree_g1/dump_mjlab_reference.py +30 -0
- diffneusim/models/source/unitree_g1/g1.xml +308 -0
- diffneusim/models/source/unitree_g1/g1_constants.py +298 -0
- diffneusim/models/source/unitree_g1/mjlab_compiled_reference.json +857 -0
- diffneusim/models/unitree_g1.dnmodel +4393 -0
- diffneusim/models/unitree_g1_selfcol.dnmodel +20824 -0
- diffneusim/rl/__init__.py +2 -0
- diffneusim/rl/dynsyn_layer.py +146 -0
- diffneusim/rl/footstep_plan.py +337 -0
- diffneusim/rl/g1_bm_env.py +572 -0
- diffneusim/rl/g1_bm_eval.py +168 -0
- diffneusim/rl/g1_bm_fused.py +275 -0
- diffneusim/rl/g1_bm_ppo.py +622 -0
- diffneusim/rl/g1_bm_sapo.py +551 -0
- diffneusim/rl/g1_ppo.py +395 -0
- diffneusim/rl/g1_sapo_soft.py +240 -0
- diffneusim/rl/g1_soft_env.py +452 -0
- diffneusim/rl/g1_soft_grad.py +145 -0
- diffneusim/rl/geyer_curves_torch.py +108 -0
- diffneusim/rl/gpu_fullbody_vec_env.py +1241 -0
- diffneusim/rl/imitation.py +2027 -0
- diffneusim/rl/imitation_reward_v2.py +248 -0
- diffneusim/rl/imitation_reward_v3.py +349 -0
- diffneusim/rl/latent_task.py +175 -0
- diffneusim/rl/llc_reward.py +316 -0
- diffneusim/rl/millard_curves_torch.py +154 -0
- diffneusim/rl/mirror_symmetry.py +212 -0
- diffneusim/rl/model_path.py +35 -0
- diffneusim/rl/mvae_recon.py +123 -0
- diffneusim/rl/nets_shac.py +599 -0
- diffneusim/rl/reset_pool.py +154 -0
- diffneusim/rl/sapo_capture.py +873 -0
- diffneusim/rl/sapo_vec.py +1051 -0
- diffneusim/rl/shac_vec.py +346 -0
- diffneusim/rl/state_prior.py +151 -0
- diffneusim/rl/step_library.py +105 -0
- diffneusim/rl/task_walk_env.py +1793 -0
- diffneusim/rl/task_walk_reward.py +3300 -0
- diffneusim/run.py +23 -0
- diffneusim/run_env.py +46 -0
- diffneusim/tasks/__init__.py +147 -0
- diffneusim/tasks/legacy_names.py +63 -0
- diffneusim/tasks/paths.py +79 -0
- diffneusim/tasks/settings.py +202 -0
- diffneusim/third_party/instantmimic_947430ee/LICENSE +202 -0
- diffneusim/third_party/instantmimic_947430ee/NOTICE +19 -0
- diffneusim/third_party/instantmimic_947430ee/README.md +31 -0
- diffneusim/third_party/instantmimic_947430ee/instantmimic/envs/unitree_g1/tasks/beyondmimic_tracking/benchmark_protocol.py +106 -0
- diffneusim/third_party/instantmimic_947430ee/instantmimic/envs/unitree_g1/tasks/beyondmimic_tracking/metrics.py +214 -0
- diffneusim/third_party/instantmimic_947430ee/instantmimic/envs/unitree_g1/tasks/beyondmimic_tracking/reference.py +513 -0
- diffneusim/third_party/instantmimic_947430ee/instantmimic/motion/quaternion.py +193 -0
- diffneusim/train/__init__.py +0 -0
- diffneusim/train/eval_ckpt.py +239 -0
- diffneusim/train/eval_mimic.py +133 -0
- diffneusim/train/gait_report.py +203 -0
- diffneusim/train/gcot_chain.py +51 -0
- diffneusim/train/levers.py +135 -0
- diffneusim/train/masked_reset.py +314 -0
- diffneusim/train/rl_algorithm_suite.py +917 -0
- diffneusim/train/train14.py +240 -0
- diffneusim/train/train_tw14.py +674 -0
- diffneusim/viz/__init__.py +5 -0
- diffneusim/viz/__main__.py +41 -0
- diffneusim/viz/camera.py +115 -0
- diffneusim/viz/dnrec.py +118 -0
- diffneusim/viz/dnrec_io.py +686 -0
- diffneusim/viz/hud.py +565 -0
- diffneusim/viz/meshes.py +458 -0
- diffneusim/viz/play.py +237 -0
- diffneusim/viz/record.py +74 -0
- diffneusim/viz/render.py +1402 -0
- diffneusim/viz/renderer.py +268 -0
- diffneusim/viz/rl_env_render.py +635 -0
- diffneusim/viz/snapshot.py +54 -0
- diffneusim/viz/strobe.py +124 -0
- diffneusim/viz/to_mp4.py +58 -0
- diffneusim/viz/ui.py +481 -0
- diffneusim/viz/viewer.py +2086 -0
- diffneusim-1.0.0.dist-info/METADATA +226 -0
- diffneusim-1.0.0.dist-info/RECORD +682 -0
- diffneusim-1.0.0.dist-info/WHEEL +5 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSE +201 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/BSD-3-Clause-NC-ARMS-hand-wrist-4.3.txt +20 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/BSD-3-Clause-NC-MoBL-ARMS.txt +25 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/CC-BY-3.0-OpenSim-geometry.txt +25 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Christophy2012-lumbarspine.txt +10 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Lai2017-model-high-flex.txt +10 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Lee2015-hand_muscle.txt +11 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Rajagopal2016-full_body.txt +11 -0
- diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Uhlrich2022-fbmodpassivecal.txt +10 -0
- diffneusim-1.0.0.dist-info/licenses/NOTICE +274 -0
- diffneusim-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,917 @@
|
|
|
1
|
+
"""The training suite every paper run goes through: SAPO on the full-body muscle environment.
|
|
2
|
+
|
|
3
|
+
It trains SapoVec on GpuFullBodyVecEnv, saves checkpoints and run_config.json, records an evaluation rollout
|
|
4
|
+
(.dnrec), reports control-step throughput, and can render the saved rollouts.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import argparse
|
|
10
|
+
import csv
|
|
11
|
+
import datetime
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import pathlib
|
|
15
|
+
import socket
|
|
16
|
+
import subprocess
|
|
17
|
+
import sys
|
|
18
|
+
import time
|
|
19
|
+
from dataclasses import dataclass
|
|
20
|
+
|
|
21
|
+
import numpy as np
|
|
22
|
+
import torch
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
from diffneusim._paths import ROOT as ROOT # (3a) the repo root
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def import_rl():
|
|
29
|
+
from diffneusim.rl.sapo_vec import SapoVec
|
|
30
|
+
|
|
31
|
+
return SapoVec
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass(frozen=True)
|
|
35
|
+
class EnvConfig:
|
|
36
|
+
n_env: int
|
|
37
|
+
epochs: int
|
|
38
|
+
steps_num: int
|
|
39
|
+
episode_length: int
|
|
40
|
+
actor_bias: float | None = None
|
|
41
|
+
substeps: int = 1
|
|
42
|
+
action_grad_clip: float | None = None # per-env action-gradient clip
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
DEFAULT_CONFIGS = {
|
|
46
|
+
"fullbody": EnvConfig(n_env=256, epochs=300, steps_num=32, episode_length=300, actor_bias=-1.5, action_grad_clip=2.0, substeps=20), # nq115/nm416 full-body (heavy -> modest n_env; verify VRAM). substeps=20 (dt=1/600). ref via DN_REF. actor_bias=-1.5 = myoLeg parity: a_max is now 1.0 (no cap, after the arm-armature fix), so rest u=0.5*(tanh(-1.5)+1)=0.047 (relaxed muscles + healthy pathwise gradient). (Was -0.5 while a_max=0.3 capped the map to u=0.014.)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
COMMON = dict(
|
|
51
|
+
gamma=0.99,
|
|
52
|
+
lam=0.95,
|
|
53
|
+
actor_lr=2e-3,
|
|
54
|
+
critic_lr=2e-3,
|
|
55
|
+
lr_schedule="linear",
|
|
56
|
+
num_batch=4,
|
|
57
|
+
grad_norm=1.0,
|
|
58
|
+
actor_units=(128, 64, 32),
|
|
59
|
+
critic_units=(64, 64),
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def make_env(name: str, cfg: EnvConfig, seed: int, stochastic_init: bool):
|
|
64
|
+
if name == "fullbody":
|
|
65
|
+
from diffneusim.rl.gpu_fullbody_vec_env import GpuFullBodyVecEnv
|
|
66
|
+
|
|
67
|
+
# nq115/nv114/nm416 full-body; imitation via DN_IMITATION=1 + DN_REF (env default =
|
|
68
|
+
# segmented_fullbody_ref.npz gate-green; CMU 07_01_fullbody_ref.npz NaNs at RSI). a_max=0.3 in-env.
|
|
69
|
+
ep_len = int(os.environ.get("DN_EPISODE", str(cfg.episode_length)))
|
|
70
|
+
return GpuFullBodyVecEnv(num_envs=cfg.n_env if stochastic_init else 1, device="cuda",
|
|
71
|
+
episode_length=ep_len, seed=seed, stochastic_init=stochastic_init,
|
|
72
|
+
control_hz=float(os.environ.get("DN_CONTROL_HZ", "30")),
|
|
73
|
+
substeps=int(os.environ.get("DN_SUBSTEPS", "20")),
|
|
74
|
+
# EXCITATION CEILING, 2026-10-02: the [-1, 1] -> [0, a_max] map's top. Schumacher et al.
|
|
75
|
+
# 2023 (arXiv 2309.02976, natural RL walking on 18-90-muscle models) clip every
|
|
76
|
+
# excitation to [0, 0.5]. Measured on the taskwalk control: 159 of 210 trunk muscles and
|
|
77
|
+
# 18 of 80 leg muscles exceed 0.5 in more than 5% of frames. 1.0 = no cap, bit-identical.
|
|
78
|
+
a_max=_fullbody_a_max())
|
|
79
|
+
raise ValueError(name)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _fullbody_a_max():
|
|
83
|
+
v = 1.0
|
|
84
|
+
return v
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def make_algo(algo_name: str, env, cfg: EnvConfig, seed: int):
|
|
88
|
+
SapoVec = import_rl()
|
|
89
|
+
common = dict(COMMON)
|
|
90
|
+
# Net-size knobs (all algos; default = COMMON => byte-identical). E.g. DN_ACTOR_UNITS=1024,1024,512
|
|
91
|
+
# widens the actor so the last hidden >= action dim (the (128,64,32) default funnels 416 muscles
|
|
92
|
+
# through a 32-wide bottleneck). Comma list of ints.
|
|
93
|
+
def _units_env(name, default):
|
|
94
|
+
v = os.environ.get(name)
|
|
95
|
+
return tuple(int(x) for x in v.split(",") if x.strip()) if v else default
|
|
96
|
+
common["actor_units"] = _units_env("DN_ACTOR_UNITS", COMMON["actor_units"])
|
|
97
|
+
common["critic_units"] = _units_env("DN_CRITIC_UNITS", COMMON["critic_units"])
|
|
98
|
+
common["actor_out_bias"] = cfg.actor_bias
|
|
99
|
+
if "DN_OUT_BIAS" in os.environ: # general exploration override (all algos): fair start (0 -> activation ~0.5)
|
|
100
|
+
common["actor_out_bias"] = None if os.environ["DN_OUT_BIAS"] == "none" else float(os.environ["DN_OUT_BIAS"])
|
|
101
|
+
common["logstd_init"] = -1.0 # exploration std (all algos); 0 -> std 1.0
|
|
102
|
+
common["max_epochs"] = cfg.epochs
|
|
103
|
+
# SHAC BPTT/credit horizon. Overridable (DN_STEPS_NUM) for the horizon study: the myoLeg26
|
|
104
|
+
# imitation policy leaves the stance extensors idle and sinks-collapses right at the steps_num=32
|
|
105
|
+
# window edge, where the pathwise gradient can't penalise it -> a longer horizon puts the collapse
|
|
106
|
+
# inside the credit window. Single-variable (reward/ET/n_env unchanged); justify results in METHODS.
|
|
107
|
+
common["steps_num"] = int(os.environ.get("DN_STEPS_NUM", cfg.steps_num))
|
|
108
|
+
# Per-step discount and TD(lambda) (all algos; unset = COMMON => byte-identical). For a cell at another control rate that keeps
|
|
109
|
+
# the per-SECOND discounting of a 100-Hz parent: gamma_hz = 0.99 ** (100 / hz), lambda likewise (dlrepro2 at 30 Hz: 0.96705,
|
|
110
|
+
# 0.84284). Both are recorded in run_config's hyperparameters. The MuscleVAE 20 Hz rung sets them the same way (0.99^5,
|
|
111
|
+
# 0.95^5 keep the 100 Hz recipe's horizons in seconds).
|
|
112
|
+
if "DN_GAMMA" in os.environ:
|
|
113
|
+
common["gamma"] = float(os.environ["DN_GAMMA"])
|
|
114
|
+
assert 0.0 < common["gamma"] < 1.0, common["gamma"]
|
|
115
|
+
common["seed"] = seed
|
|
116
|
+
common["device"] = "cuda"
|
|
117
|
+
# action_grad_clip override (all algos): DN_ACTION_GRAD_CLIP=none disables the per-env clip so the
|
|
118
|
+
# raw FoBG explosion is visible (= IVW-H's job to tame); a float overrides cfg. Default = cfg value.
|
|
119
|
+
_agc = os.environ.get("DN_ACTION_GRAD_CLIP")
|
|
120
|
+
agc = cfg.action_grad_clip if _agc is None else (None if _agc.lower() == "none" else float(_agc))
|
|
121
|
+
_latent_knobs = sorted(k for k in os.environ if k.startswith("DN_LATENT_") and not k.startswith("DN_LATENT_TASK"))
|
|
122
|
+
assert not _latent_knobs, f"{_latent_knobs} set without DN_LATENT=1"
|
|
123
|
+
_ltask_knobs = sorted(k for k in os.environ if k.startswith("DN_LATENT_TASK_"))
|
|
124
|
+
assert not _ltask_knobs, f"{_ltask_knobs} set without DN_LATENT_TASK=1"
|
|
125
|
+
if algo_name == "sapo":
|
|
126
|
+
# SAPO (Xing et al. ICLR 2025, arXiv:2412.12089) = SHAC + maximum-entropy: state-dependent
|
|
127
|
+
# squashed-Normal actor, double critic (no target net), entropy-augmented return + td-lambda
|
|
128
|
+
# target, auto-tuned temperature. Paper recipe: SiLU + LayerNorm, AdamW (0.7,0.95), actor 2e-3 /
|
|
129
|
+
# critic 5e-4 / alpha 5e-3, grad-clip 0.5, gamma 0.99, td-lambda 0.95, horizon 32, ensemble n=2.
|
|
130
|
+
# Actor/critic net-size + LR + out_bias overrides are shared with SHAC/RPO (DN_* env vars);
|
|
131
|
+
# the SAPO-specific knobs are SAPO_* (n_critics / init_alpha / alpha_lr / target_entropy_scalar).
|
|
132
|
+
sapo_kw = dict(common)
|
|
133
|
+
sapo_kw["critic_lr"] = 0.0005 # SAPO paper critic lr
|
|
134
|
+
sapo_kw["actor_lr"] = float(sapo_kw["actor_lr"])
|
|
135
|
+
sapo_kw["grad_norm"] = 0.5 # SAPO paper grad-norm clip
|
|
136
|
+
sapo_kw["action_grad_clip"] = agc # per-env FoBG cap (cfg default 2.0): env-level taming of the stiff-contact full-body pathwise-grad explosion (orthogonal to SAPO's entropy)
|
|
137
|
+
return SapoVec(
|
|
138
|
+
env,
|
|
139
|
+
activation="silu",
|
|
140
|
+
n_critics=2,
|
|
141
|
+
init_alpha=float(os.environ.get("SAPO_INIT_ALPHA", "1.0")),
|
|
142
|
+
alpha_lr=0.005,
|
|
143
|
+
target_entropy_scalar=float(os.environ.get("SAPO_TARGET_ENTROPY_SCALAR", "0.5")),
|
|
144
|
+
# the entropy block (SapoVec.entropy_dims): a json {"dims": [...]} from tools/sapo_entropy_dims.py; unset = every dim
|
|
145
|
+
entropy_dims=None,
|
|
146
|
+
# AHAC adaptive-horizon (opt-in; SAPO_AHAC=0 default => byte-identical fixed-H SAPO). C is in
|
|
147
|
+
# actor grad-norm units and MUST be calibrated per model. STEPS_MAX caps the BPTT window (<=
|
|
148
|
+
# cfg.steps_num); SHORTEN=1 shrinks H when gn>C (our "cap before it explodes"), 0 = paper sign.
|
|
149
|
+
adaptive_horizon=False,
|
|
150
|
+
ahac_steps_min=8,
|
|
151
|
+
ahac_steps_max=None,
|
|
152
|
+
ahac_C=None,
|
|
153
|
+
ahac_lambd_lr=0.0001,
|
|
154
|
+
ahac_shorten_on_stiff=True,
|
|
155
|
+
# per-env AHAC cut (SAPO_PEC=0 default => byte-identical). pec_C = ground-contact-force (N)
|
|
156
|
+
# threshold. SAPO_PEC_CUT_CRITIC=1 additionally treats a cut as terminal in the critic's
|
|
157
|
+
# td-lambda recursion (the pre-2026-07-27 coupled behavior); default 0 = gradient-only cut.
|
|
158
|
+
per_env_cut=False,
|
|
159
|
+
pec_C=None,
|
|
160
|
+
pec_cut_critic=False,
|
|
161
|
+
# critic warm-up for a warm start (SapoVec.actor_freeze_epochs); 0 default => byte-identical
|
|
162
|
+
actor_freeze_epochs=0,
|
|
163
|
+
# the actor's optimiser (SapoVec.__init__): adamw default => byte-identical; sgd = the gradient, lr x the scale
|
|
164
|
+
actor_opt=os.environ.get("SAPO_ACTOR_OPT", "adamw"),
|
|
165
|
+
actor_sgd_lr_scale=float(os.environ.get("SAPO_ACTOR_SGD_LR_SCALE", "1.0")),
|
|
166
|
+
# the new input columns' own step (SapoVec.__init__ NEW-INPUT STEP): 0 / 1.0 default => byte-identical
|
|
167
|
+
new_input_cols=0,
|
|
168
|
+
new_input_lr_mult=1.0,
|
|
169
|
+
**sapo_kw,
|
|
170
|
+
)
|
|
171
|
+
raise ValueError(algo_name)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def _v2_log_fields(env):
|
|
175
|
+
"""Flat float fields describing IM_V2's adaptive state, or {} when IM_V2 is off.
|
|
176
|
+
|
|
177
|
+
Flattened rather than nested because the per-epoch log is written to a JSON list AND summarised into a
|
|
178
|
+
CSV, and a nested dict survives neither cleanly. Per-component weights are emitted for the groups whose
|
|
179
|
+
internal balance is the thing under study; the rest get their summary statistics only, to keep the
|
|
180
|
+
record readable.
|
|
181
|
+
"""
|
|
182
|
+
t = getattr(env, "imitation_task", None)
|
|
183
|
+
v3 = getattr(t, "_v3", None) if t is not None else None
|
|
184
|
+
if v3 is not None:
|
|
185
|
+
st = v3.state()
|
|
186
|
+
out = {"v3_huber_delta": float(st["huber_delta"]),
|
|
187
|
+
# which exponents are still placeholders: a later reader must be able to tell whether this
|
|
188
|
+
# run's group balance was measured or guessed, from the log alone
|
|
189
|
+
"v3_alpha_provisional": ",".join(st["alpha_provisional"]) or "none",
|
|
190
|
+
"v3_taskvel": int(bool(getattr(t, "IM_V3_TASKVEL", False)))}
|
|
191
|
+
out["v3_clip_norm"] = int(bool(st["clip_norm"]))
|
|
192
|
+
for g, a_ in st["alpha"].items():
|
|
193
|
+
out[f"v3_alpha_{g}"] = float(a_)
|
|
194
|
+
out[f"v3_alpha_src_{g}"] = st["alpha_src"][g]
|
|
195
|
+
out[f"v3_W_{g}"] = float(st["W"][g])
|
|
196
|
+
# the exponent ACTUALLY used is alpha_base * clip_factor, and the factor is the one thing here that
|
|
197
|
+
# changes with the reference: logging alpha without it says nothing about what the run did
|
|
198
|
+
out[f"v3_alpha_base_{g}"] = float(st["alpha_base"][g])
|
|
199
|
+
out[f"v3_clip_factor_{g}"] = float(st["clip_factor"][g])
|
|
200
|
+
if g in st["clip_scale"]:
|
|
201
|
+
out[f"v3_ref_scale_{g}"] = float(st["clip_scale"][g])
|
|
202
|
+
for g in ("joint", "jointvel"): # the A^2-weighted groups; task/ang/taskvel/angvel are all 1.0
|
|
203
|
+
if g in st["w"]:
|
|
204
|
+
for nm, wv in zip(st["names"][g], st["w"][g]):
|
|
205
|
+
out[f"v3_w_{g}_{nm}"] = float(wv)
|
|
206
|
+
# E_g PER EPOCH -- the only thing here that is a time series. v3's alpha/W/w are static by
|
|
207
|
+
# construction, so logging them is recording config; what a later analysis actually needs is the
|
|
208
|
+
# tracking error itself, per group, as training proceeds. v2's run left no history at all and its
|
|
209
|
+
# faults had to be reconstructed from rollouts; emitting config alone would repeat that mistake in a
|
|
210
|
+
# new shape. `_v3_last_E` is the detached batch of group errors from the most recent reward() call,
|
|
211
|
+
# so this is the batch mean at the moment the epoch was logged, not an average over the epoch.
|
|
212
|
+
lastE = getattr(t, "_v3_last_E", None)
|
|
213
|
+
if lastE:
|
|
214
|
+
for g, E in lastE.items():
|
|
215
|
+
out[f"v3_Elast_{g}"] = float(E.mean())
|
|
216
|
+
out[f"v3_E_{g}_p90"] = float(E.quantile(0.9)) # the tail is what v2's alpha could not see
|
|
217
|
+
# EPOCH means, and the PER-COMPONENT breakdown underneath them. `_v3_last_E` above is one control step
|
|
218
|
+
# out of the ~32 x n_env an epoch takes; these are accumulated on the device across the whole epoch
|
|
219
|
+
# (no per-step sync) and reset here. The breakdown is the diagnostic that fb_v9_imv2 lacked: `joint` is
|
|
220
|
+
# 82% the two hip quaternions and hip_flexion_l carries 1.7x hip_flexion_r, so whether the asymmetry
|
|
221
|
+
# closes is answerable from the log alone instead of from a separate rollout.
|
|
222
|
+
ep = t._v3_epoch_errors() if hasattr(t, "_v3_epoch_errors") else {}
|
|
223
|
+
for g, comps in ep.items():
|
|
224
|
+
w = dict(zip(st["names"][g], st["w"][g]))
|
|
225
|
+
out[f"v3_E_{g}"] = float(sum(w[nm] * e for nm, e in comps.items())) # = sum_j w_j * mean(e_j)
|
|
226
|
+
for nm, e in comps.items():
|
|
227
|
+
out[f"v3_e_{g}_{nm}"] = float(e)
|
|
228
|
+
return out
|
|
229
|
+
v2 = getattr(t, "_v2", None) if t is not None else None
|
|
230
|
+
if v2 is None:
|
|
231
|
+
return {}
|
|
232
|
+
st = v2.state()
|
|
233
|
+
out = {"v2_beta": float(st["beta"])}
|
|
234
|
+
for g, a in st["alpha"].items():
|
|
235
|
+
out[f"v2_alpha_{g}"] = float(a)
|
|
236
|
+
out[f"v2_Eema_{g}"] = float(st["E_ema"][g])
|
|
237
|
+
s = st["s"][g]
|
|
238
|
+
out[f"v2_s_spread_{g}"] = float(max(s) / max(min(s), 1e-12))
|
|
239
|
+
for g in ("ang", "pos"):
|
|
240
|
+
if g in st["s"]:
|
|
241
|
+
for nm, sv in zip(st["names"][g], st["s"][g]):
|
|
242
|
+
out[f"v2_s_{g}_{nm}"] = float(sv)
|
|
243
|
+
return out
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def policy_action(env, algo, obs, deterministic):
|
|
247
|
+
"""The eval policy's PRE-tanh action for `obs`. A latent-skill-model policy (DN_LATENT) in tracking mode also
|
|
248
|
+
reads the env's next-reference block for its posterior; in generation mode (algo.latent_eval_mode) it samples z from
|
|
249
|
+
the prior and reads no reference. The latent model's task phase (DN_LATENT_TASK) reads the env's command block.
|
|
250
|
+
Every other policy: algo.act(obs) exactly as before."""
|
|
251
|
+
if getattr(algo, "ltask", False):
|
|
252
|
+
return algo.act(obs, deterministic=deterministic, task_raw=env.latent_task_obs())
|
|
253
|
+
if getattr(algo, "latent", None) is None or algo.latent_eval_mode == "generation":
|
|
254
|
+
return algo.act(obs, deterministic=deterministic)
|
|
255
|
+
return algo.act(obs, deterministic=deterministic, ref_raw=env.latent_ref_obs())
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def eval_and_record(env_name: str, env, algo, out_npz: pathlib.Path, deterministic: bool = True):
|
|
259
|
+
assert env_name == "fullbody", env_name
|
|
260
|
+
# deterministic=False records the TRAINING policy (sampled actions): SAPO optimises the sampled policy's
|
|
261
|
+
# return, and its mean action can be a different gait (2026-10-09: the w(3) probe's mean controller
|
|
262
|
+
# crouched and fell while the sampled policy walked and gained reward).
|
|
263
|
+
obs = env.reset()
|
|
264
|
+
if hasattr(env, "eval_mode"):
|
|
265
|
+
env.eval_mode = True # eval measures SUSTAINED behavior: disable the imitation early-termination
|
|
266
|
+
# (only the real fall gate ends the eval), so it isn't truncated at first desync
|
|
267
|
+
# The clip and phase env 0 starts on: a multi-clip eval draws them inside this reset, so without them a
|
|
268
|
+
# start's survival cannot be attributed to a motion (walk, run or jumps).
|
|
269
|
+
_im0 = env.imitation_task if getattr(env, "imitation", False) and getattr(env, "imitation_task", None) else None
|
|
270
|
+
_start_clip = (int(_im0.clip_id[0]), float(env.phase[0])) if _im0 is not None else None
|
|
271
|
+
qs = [env.q[:, 0].detach().cpu().numpy()]
|
|
272
|
+
qds = [env.qd[:, 0].detach().cpu().numpy()]
|
|
273
|
+
rewards = []
|
|
274
|
+
lces = []
|
|
275
|
+
activations = []
|
|
276
|
+
zs = []
|
|
277
|
+
lces.append(env.lce[:, 0].detach().cpu().numpy())
|
|
278
|
+
activations.append(env.a[:, 0].detach().cpu().numpy())
|
|
279
|
+
zs.append(env.z[:, 0].detach().cpu().numpy())
|
|
280
|
+
# De-teleport the loop clip: ref_at(phase) carries the clip's ABSOLUTE root, which snaps back to the
|
|
281
|
+
# start every time phase wraps 1->0 (a visible backward jump each gait cycle). Accumulate the per-loop
|
|
282
|
+
# root advance D and add it so the ghost walks forward CONTINUOUSLY alongside the policy.
|
|
283
|
+
# PER CLIP. `ref_q` is the CONCATENATION of the whole corpus under multi-clip, so the old
|
|
284
|
+
# `ref_q[-1] - ref_q[0]` was "the last clip's end minus the FIRST clip's start" -- on the 115-clip corpus
|
|
285
|
+
# that is [0.933, 0.002, 0.013] against 08_01's true per-cycle advance of [1.657, 0, -0.002], so the ghost
|
|
286
|
+
# fell 0.72 m behind at EVERY wrap and looked like it teleported. Read env 0's own clip instead.
|
|
287
|
+
_gh_off = np.zeros(3, dtype=np.float32)
|
|
288
|
+
_gh_prev = [None]
|
|
289
|
+
_gh_D = None
|
|
290
|
+
def _grab_ref():
|
|
291
|
+
ph = float(env.phase[0])
|
|
292
|
+
if _gh_prev[0] is not None and ph < _gh_prev[0] - 0.5: # phase wrapped 1->0 this step
|
|
293
|
+
_gh_off[:] = _gh_off + _gh_D
|
|
294
|
+
_gh_prev[0] = ph
|
|
295
|
+
t = env.imitation_task
|
|
296
|
+
q = t.ref_at(env.phase)[0][:, 0].detach().cpu().numpy().copy() # (nq,) env 0
|
|
297
|
+
# THE ROOT TRANSLATION IS REBUILT HERE rather than taken from ref_at. ref_at interpolates CYCLICALLY,
|
|
298
|
+
# so its last segment blends the clip's final frame with its FIRST -- and while a loop reference closes
|
|
299
|
+
# its JOINTS, the absolute root xy ADVANCES by a full stride over the cycle (1.657 m on 08_01). The
|
|
300
|
+
# blend therefore drags the root backwards for one frame before the wrap, which is the "reference
|
|
301
|
+
# teleports" artifact in a ghost overlay.
|
|
302
|
+
#
|
|
303
|
+
# This is fixed HERE, in the recorder, and NOT in ref_at: the reward deliberately never sees the
|
|
304
|
+
# absolute root xy (Morphology.build excludes root_fwd/root_lat from pose_scalar_idx, and every task
|
|
305
|
+
# term is root-relative), so ref_at's behaviour is harmless to training and changing a function on the
|
|
306
|
+
# training path to make a video look right would be the wrong trade.
|
|
307
|
+
i0, i1, wf = t.frame_idx(env.phase)
|
|
308
|
+
i0, i1, wf = int(i0[0]), int(i1[0]), float(wf[0])
|
|
309
|
+
p0 = t.ref_q[i0, :3].detach().cpu().numpy().astype(np.float64)
|
|
310
|
+
p1 = t.ref_q[i1, :3].detach().cpu().numpy().astype(np.float64)
|
|
311
|
+
if i1 <= i0: # i1 wrapped to the clip start: carry it forward by one cycle
|
|
312
|
+
p1 = p1 + _gh_D.astype(np.float64)
|
|
313
|
+
q[:3] = (p0 * (1.0 - wf) + p1 * wf) + _gh_off
|
|
314
|
+
return q
|
|
315
|
+
# TASKWALK_FOOTSTEPS: env 0's footstep plan at every recorded frame (world p0, p1, the plan heading, provisional, left
|
|
316
|
+
# stance), aligned 1:1 with `qs`, for the renderer's map (eval_ckpt stamps it into the task block)
|
|
317
|
+
_fs = getattr(env, "_tw_fs", None)
|
|
318
|
+
fs_rec = []
|
|
319
|
+
def _grab_fs():
|
|
320
|
+
return [float(_fs.p0[0, 0]), float(_fs.p0[1, 0]), float(_fs.p1[0, 0]), float(_fs.p1[1, 0]), float(_fs.heading[0]),
|
|
321
|
+
float(_fs.pending[0]), float(_fs.stance_left[0])]
|
|
322
|
+
if _fs is not None:
|
|
323
|
+
fs_rec.append(_grab_fs())
|
|
324
|
+
alive = 0
|
|
325
|
+
with torch.no_grad():
|
|
326
|
+
for _ in range(env.episode_length):
|
|
327
|
+
action = torch.tanh(policy_action(env, algo, obs, deterministic))
|
|
328
|
+
obs, rew, done, _extra = env.step(action)
|
|
329
|
+
rewards.append(float(rew[0].detach()))
|
|
330
|
+
alive += 1 # count the step just completed (BEFORE the
|
|
331
|
+
# done-check) -- else a natural episode-end (progress>=episode_length, NOT a failure) breaks
|
|
332
|
+
# before counting its last step, giving the systematic off-by-one (239/240, 299/300, 999/1000).
|
|
333
|
+
if bool(done[0]):
|
|
334
|
+
break
|
|
335
|
+
qs.append(env.q[:, 0].detach().cpu().numpy())
|
|
336
|
+
qds.append(env.qd[:, 0].detach().cpu().numpy())
|
|
337
|
+
if _fs is not None:
|
|
338
|
+
fs_rec.append(_grab_fs())
|
|
339
|
+
lces.append(env.lce[:, 0].detach().cpu().numpy())
|
|
340
|
+
activations.append(env.a[:, 0].detach().cpu().numpy())
|
|
341
|
+
zs.append(env.z[:, 0].detach().cpu().numpy())
|
|
342
|
+
payload = {
|
|
343
|
+
"q": np.stack(qs),
|
|
344
|
+
"qd": np.stack(qds),
|
|
345
|
+
"reward": np.asarray(rewards, dtype=np.float64),
|
|
346
|
+
"dt": control_dt(env_name, env),
|
|
347
|
+
"survived_steps": alive,
|
|
348
|
+
}
|
|
349
|
+
# the muscle overlay's inputs (rl_env_render builds the mtu_poly from 'activation')
|
|
350
|
+
payload.update(lce=np.stack(lces), activation=np.stack(activations), z=np.stack(zs))
|
|
351
|
+
# .dnrec is the ONE artifact: a self-contained record (embeds model + full sim state), built DIRECTLY
|
|
352
|
+
# from the in-memory rollout dict -- NEVER a .npz, never an npz->dnrec conversion; gait_report and the
|
|
353
|
+
# renderer both read the .dnrec.
|
|
354
|
+
from diffneusim.viz.rl_env_render import SUPPORTED as _DNREC_ENVS, render_npz_to_dnrec
|
|
355
|
+
out_str = str(out_npz)
|
|
356
|
+
dnrec_path = (out_str[:-len(".npz")] if out_str.endswith(".npz") else
|
|
357
|
+
out_str[:-len(".dnrec")] if out_str.endswith(".dnrec") else out_str) + ".dnrec"
|
|
358
|
+
assert env_name in _DNREC_ENVS, f"{env_name} is not dnrec-native -- add it to rl_env_render.DNMODEL_ENVS"
|
|
359
|
+
# SUITE_SKIP_DNREC: eval_curve re-runs eval_and_record per checkpoint only for the metrics; the
|
|
360
|
+
# per-ckpt .dnrec build (full-episode FK) is the bottleneck there and is not needed for the curve.
|
|
361
|
+
if not os.environ.get("SUITE_SKIP_DNREC"):
|
|
362
|
+
render_npz_to_dnrec(env_name, payload, dnrec_path) # dict source -> no intermediate npz
|
|
363
|
+
q = payload["q"]
|
|
364
|
+
fwd = float(q[-1, 0] - q[0, 0]) if q.shape[1] > 0 else 0.0
|
|
365
|
+
h_mean = float(q[:, 2].mean())
|
|
366
|
+
ret = float(np.sum(payload["reward"]))
|
|
367
|
+
result = dict(eval_return=ret, eval_steps=int(alive), eval_fwd=fwd, eval_height_mean=h_mean,
|
|
368
|
+
rollout_dnrec=dnrec_path)
|
|
369
|
+
if _start_clip is not None:
|
|
370
|
+
result.update(start_clip=pathlib.Path(_im0.clip_paths[_start_clip[0]]).stem, start_phase=_start_clip[1])
|
|
371
|
+
if _fs is not None:
|
|
372
|
+
result["footsteps"] = fs_rec
|
|
373
|
+
return result
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
def eval_and_record_batch(env_name: str, env, algo, out_paths, deterministic: bool = True):
|
|
377
|
+
"""eval_and_record for ALL the env's envs AT ONCE: env i is start i, recorded until its FIRST done (the env
|
|
378
|
+
autoresets it afterwards and that tail is ignored). Same deterministic policy, same per-start payload and
|
|
379
|
+
.dnrec as eval_and_record, same metrics. ~N x faster on a GPU that is launch-bound at n_env = 1.
|
|
380
|
+
|
|
381
|
+
NOT bit-comparable with the sequential eval: the N starts are drawn in ONE reset instead of N successive ones,
|
|
382
|
+
so the stochastic-init RNG hands out different starts. Compare batched evals with batched evals. No ghost
|
|
383
|
+
overlay."""
|
|
384
|
+
assert env_name == "fullbody", env_name
|
|
385
|
+
n = int(env.num_envs)
|
|
386
|
+
assert len(out_paths) == n, (len(out_paths), n)
|
|
387
|
+
obs = env.reset()
|
|
388
|
+
if hasattr(env, "eval_mode"):
|
|
389
|
+
env.eval_mode = True
|
|
390
|
+
grab = lambda t: t.detach().cpu().numpy().T.copy() # (dim, n) -> (n, dim) # noqa: E731
|
|
391
|
+
qs, qds, lces, acts, zs = [grab(env.q)], [grab(env.qd)], [grab(env.lce)], [grab(env.a)], [grab(env.z)]
|
|
392
|
+
# TASKWALK_FOOTSTEPS: every env's plan at every recorded frame, the sequential eval's seven columns (world p0, p1, the plan
|
|
393
|
+
# heading, provisional, left stance), so a batched record carries its map too
|
|
394
|
+
_fs = getattr(env, "_tw_fs", None)
|
|
395
|
+
def _grab_fs():
|
|
396
|
+
return torch.stack([_fs.p0[0], _fs.p0[1], _fs.p1[0], _fs.p1[1], _fs.heading, _fs.pending.to(_fs.heading.dtype),
|
|
397
|
+
_fs.stance_left.to(_fs.heading.dtype)], 1).detach().cpu().numpy().astype(np.float64) # (n, 7)
|
|
398
|
+
fss = [_grab_fs()] if _fs is not None else None
|
|
399
|
+
rewards = []
|
|
400
|
+
alive = np.zeros(n, dtype=np.int64)
|
|
401
|
+
live = np.ones(n, dtype=bool)
|
|
402
|
+
with torch.no_grad():
|
|
403
|
+
for _ in range(env.episode_length):
|
|
404
|
+
action = torch.tanh(policy_action(env, algo, obs, deterministic))
|
|
405
|
+
obs, rew, done, _extra = env.step(action)
|
|
406
|
+
rewards.append(rew.detach().cpu().numpy().astype(np.float64))
|
|
407
|
+
alive += live # the step just completed, as in eval_and_record
|
|
408
|
+
d = done.detach().cpu().numpy().astype(bool)
|
|
409
|
+
live &= ~d
|
|
410
|
+
if not live.any():
|
|
411
|
+
break
|
|
412
|
+
qs.append(grab(env.q)); qds.append(grab(env.qd)); lces.append(grab(env.lce))
|
|
413
|
+
acts.append(grab(env.a)); zs.append(grab(env.z))
|
|
414
|
+
if fss is not None:
|
|
415
|
+
fss.append(_grab_fs())
|
|
416
|
+
from diffneusim.viz.rl_env_render import render_npz_to_dnrec
|
|
417
|
+
Q, QD, L, A, Z = (np.stack(x) for x in (qs, qds, lces, acts, zs)) # (T, n, dim)
|
|
418
|
+
R = np.stack(rewards) # (T_steps, n)
|
|
419
|
+
out = []
|
|
420
|
+
for i in range(n):
|
|
421
|
+
k = int(alive[i]) # steps completed; like eval_and_record the record holds k frames: the reset
|
|
422
|
+
nf = max(k, 1) # frame and one after every step but the last (the done step is not appended)
|
|
423
|
+
payload = {"q": Q[:nf, i], "qd": QD[:nf, i], "reward": R[:k, i], "dt": control_dt(env_name, env),
|
|
424
|
+
"survived_steps": k, "lce": L[:nf, i], "activation": A[:nf, i], "z": Z[:nf, i]}
|
|
425
|
+
s_ = str(out_paths[i])
|
|
426
|
+
dnrec_path = (s_[:-len(".dnrec")] if s_.endswith(".dnrec") else s_) + ".dnrec"
|
|
427
|
+
if not os.environ.get("SUITE_SKIP_DNREC"):
|
|
428
|
+
render_npz_to_dnrec(env_name, payload, dnrec_path)
|
|
429
|
+
q = payload["q"]
|
|
430
|
+
res = dict(eval_return=float(np.sum(payload["reward"])), eval_steps=k,
|
|
431
|
+
eval_fwd=float(q[-1, 0] - q[0, 0]), eval_height_mean=float(q[:, 2].mean()),
|
|
432
|
+
rollout_dnrec=dnrec_path)
|
|
433
|
+
if fss is not None: # aligned 1:1 with the record's frames, as eval_and_record's
|
|
434
|
+
res["footsteps"] = [[float(v) for v in fss[t][i]] for t in range(nf)]
|
|
435
|
+
out.append(res)
|
|
436
|
+
return out
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
def control_dt(env_name: str, env) -> float:
|
|
440
|
+
assert env_name == "fullbody", env_name
|
|
441
|
+
return env.SUBSTEPS * env.dt
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
# Every env-var prefix the training stack actually reads. A run's identity otherwise lives in shell
|
|
445
|
+
# history, so anything missing here is a knob whose value is unrecoverable after the fact. The old list
|
|
446
|
+
# stopped at MYOLEG/PPO/SUITE/IM_/TORCH_EXTENSIONS, which silently dropped SAPO_* -- i.e. the AHAC horizon
|
|
447
|
+
# and the whole per-env-cut family (SAPO_PEC, SAPO_PEC_C, SAPO_PEC_CUT_CRITIC) -- and FULLBODY_* including
|
|
448
|
+
# FULLBODY_DNMODEL, which selects the MODEL. Two runs differing only in pec_C produced identical records.
|
|
449
|
+
# Regenerate with:
|
|
450
|
+
# grep -rhoE 'os\.environ(\.get)?[\[\(]"[A-Z][A-Z0-9_]+"' python tools | grep -oE '"[A-Z_0-9]+"' | tr -d '"'
|
|
451
|
+
_KNOB_PREFIXES = ("MYOLEG", "SAPO_", "PPO_", "FULLBODY_", "IVW_", "SUITE_", "MYOASSIST_", "MTU_", "IMEX_", "SINK_", "LM_", "FD_", "IM_", "DN_", "TASKWALK_",
|
|
452
|
+
"TORCH_EXTENSIONS", "CUDA_VISIBLE_DEVICES",
|
|
453
|
+
# the E0 env's and the E0 trainer's knobs (E0_TERM, E0_ENGINE14, E0_ENV14_*, E0_MUSCLE_CASE; E0SPEED_LEVERS; X14_VARIANT;
|
|
454
|
+
# LEARN_ARM, LEARN_EMA): run_config.json missed every one of them before 11-05
|
|
455
|
+
"E0_", "E0SPEED_", "X14_", "LEARN_",
|
|
456
|
+
# the D16 body the engine compiles (D16_BODY, unset the 14x) and the engine's Newton count (ENGINE14_KFIB) (feat/d16-taskwalk)
|
|
457
|
+
"D16_", "ENGINE14_")
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
def write_run_config(out_dir, env, algo, env_name, algo_name, cfg, seed):
|
|
461
|
+
"""Self-documenting run record written at train start -- the config-tracking discipline so no run
|
|
462
|
+
is ever ambiguous again. Captures git commit/branch/dirty, the ACTUAL reference motion + substeps
|
|
463
|
+
the env used (not the CLI value the myoLeg env ignores), every hyperparameter, every knob env var
|
|
464
|
+
(_KNOB_PREFIXES), and the launch argv. training-benchmark.md rows reference the run dir.
|
|
465
|
+
|
|
466
|
+
Only env vars that are SET are recorded -- an unset knob took its code default AT THAT COMMIT, which
|
|
467
|
+
the recorded git sha pins."""
|
|
468
|
+
def _git(args):
|
|
469
|
+
r = subprocess.run(["git", *args], cwd=str(ROOT), capture_output=True, text=True)
|
|
470
|
+
return r.stdout.strip() if r.returncode == 0 else "unknown"
|
|
471
|
+
|
|
472
|
+
def _git_record():
|
|
473
|
+
"""commit/branch plus WHAT is dirty -- a bare `dirty: true` cannot be acted on.
|
|
474
|
+
|
|
475
|
+
A bool made every run on the training host look unattributable, because nine untracked scratch
|
|
476
|
+
probes sat in models/ (2026-07-28). Deciding whether that mattered took a manual audit each time:
|
|
477
|
+
untracked files cannot change training, MODIFIED TRACKED files silently do. So record the tracked
|
|
478
|
+
diff explicitly -- `modified` empty means the run's code and model artifacts are byte-identical to
|
|
479
|
+
`commit`, whatever else is lying around the tree.
|
|
480
|
+
"""
|
|
481
|
+
tracked = _git(["diff", "--name-only", "HEAD"])
|
|
482
|
+
modified = [p for p in tracked.splitlines() if p] if tracked != "unknown" else ["unknown"]
|
|
483
|
+
untracked = _git(["ls-files", "--others", "--exclude-standard"])
|
|
484
|
+
n_untracked = len([p for p in untracked.splitlines() if p]) if untracked != "unknown" else -1
|
|
485
|
+
return {"commit": _git(["rev-parse", "HEAD"]),
|
|
486
|
+
"branch": _git(["rev-parse", "--abbrev-ref", "HEAD"]),
|
|
487
|
+
"dirty": bool(modified), # TRACKED changes only -- the ones that alter behaviour
|
|
488
|
+
"modified": modified, # [] => sources/models identical to `commit`
|
|
489
|
+
"n_untracked": n_untracked} # context only; cannot affect the run
|
|
490
|
+
|
|
491
|
+
actor = getattr(algo, "actor", None)
|
|
492
|
+
task = getattr(env, "imitation_task", None)
|
|
493
|
+
cfg_dict = {k: getattr(cfg, k, None) for k in
|
|
494
|
+
("n_env", "epochs", "steps_num", "substeps", "episode_length", "actor_bias",
|
|
495
|
+
"action_grad_clip", "target_critic_alpha")}
|
|
496
|
+
hp = {k: getattr(algo, k, None) for k in
|
|
497
|
+
("actor_lr", "critic_lr", "gamma", "lam", "grad_norm", "ent_coef", "clip", "target_kl",
|
|
498
|
+
"update_epochs", "reuse_epochs", "kl_coef", "pathwise_coef", "num_batch", "max_epochs")}
|
|
499
|
+
record = {
|
|
500
|
+
"timestamp": datetime.datetime.now().isoformat(timespec="seconds"),
|
|
501
|
+
"host": socket.gethostname(),
|
|
502
|
+
"git": _git_record(),
|
|
503
|
+
"model": env_name, "method": algo_name, "seed": seed,
|
|
504
|
+
"reference_motion": os.environ.get("DN_REF") or getattr(task, "ref_path", None),
|
|
505
|
+
"actual_substeps": getattr(env, "SUBSTEPS", None), # authoritative (myoLeg ignores --substeps)
|
|
506
|
+
"num_obs": getattr(env, "num_obs", None), "num_actions": getattr(env, "num_actions", None),
|
|
507
|
+
"num_envs": getattr(env, "num_envs", None),
|
|
508
|
+
"logstd_init": (float(actor.logstd.detach().mean()) if actor is not None and isinstance(getattr(actor, "logstd", None), torch.Tensor) else None), # SAPO's logstd is a state-dependent Linear head, not a Parameter -> None
|
|
509
|
+
"out_bias_actual": (float([m for m in actor.mu_net if isinstance(m, torch.nn.Linear)][-1].bias.detach().mean())
|
|
510
|
+
if actor is not None and hasattr(actor, "mu_net") else None), # APPLIED out_bias (PPO_OUT_BIAS/DN_OUT_BIAS override), NOT cfg.actor_bias
|
|
511
|
+
"config": cfg_dict,
|
|
512
|
+
"hyperparameters": {k: v for k, v in hp.items() if v is not None},
|
|
513
|
+
"env_vars": {k: v for k, v in sorted(os.environ.items()) if k.startswith(_KNOB_PREFIXES)},
|
|
514
|
+
"argv": sys.argv,
|
|
515
|
+
}
|
|
516
|
+
out_dir.mkdir(parents=True, exist_ok=True)
|
|
517
|
+
(out_dir / "run_config.json").write_text(json.dumps(record, indent=2))
|
|
518
|
+
print(f"[run_config] {out_dir/'run_config.json'} ref={record['reference_motion']} "
|
|
519
|
+
f"sub={record['actual_substeps']} git={record['git']['commit'][:8]}", flush=True)
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
def ckpt_payload(algo, step_count, epoch):
|
|
523
|
+
"""The SUITE_SAVE_CKPTS checkpoint: what SUITE_INIT_CKPT and tools/eval_ckpt.py load back."""
|
|
524
|
+
payload = {"actor": algo.actor.state_dict(), "obs_rms": algo.obs_rms.state_dict(),
|
|
525
|
+
"step_count": int(step_count), "epoch": epoch}
|
|
526
|
+
# Also persist critic + log_alpha so SUITE_INIT_CKPT can resume with the value fn intact
|
|
527
|
+
# (no relearning dip) and the SAPO temperature carried over.
|
|
528
|
+
if hasattr(algo, "critic"):
|
|
529
|
+
payload["critic"] = algo.critic.state_dict()
|
|
530
|
+
if hasattr(algo, "log_alpha"):
|
|
531
|
+
payload["log_alpha"] = algo.log_alpha.detach().cpu()
|
|
532
|
+
# Adam optimizer state (moments) so SUITE_INIT_CKPT resumes without a cold-Adam dip.
|
|
533
|
+
for _oname in ("actor_opt", "critic_opt", "alpha_opt"):
|
|
534
|
+
if hasattr(algo, _oname):
|
|
535
|
+
payload[_oname] = getattr(algo, _oname).state_dict()
|
|
536
|
+
if getattr(algo, "latent", None) is not None: # the encoder + reference normaliser (the decoder is `actor`)
|
|
537
|
+
payload.update(algo.latent_state())
|
|
538
|
+
if getattr(algo, "ltask", False): # the frozen decoder + encoder it drives (the task policy is `actor`)
|
|
539
|
+
payload.update(algo.latent_task_state())
|
|
540
|
+
return payload
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
def train_one(env_name: str, algo_name: str, cfg: EnvConfig, out_dir: pathlib.Path, seed: int):
|
|
544
|
+
torch.cuda.empty_cache()
|
|
545
|
+
env = make_env(env_name, cfg, seed, stochastic_init=True)
|
|
546
|
+
algo = make_algo(algo_name, env, cfg, seed)
|
|
547
|
+
# Warm-start from a prior ckpt (env-var gated): load the ACTOR + obs_rms (always present), plus the
|
|
548
|
+
# CRITIC + log_alpha when the ckpt has them (ckpts saved after this feature). Continues a run whose
|
|
549
|
+
# actor already learned useful behavior (the suite has no optimizer-state resume; Adam moments restart,
|
|
550
|
+
# which is a brief transient). A critic-less ckpt (actor only) reinitializes the value fn -> a few-epoch
|
|
551
|
+
# relearning dip before the good actor re-climbs.
|
|
552
|
+
init_ck = os.environ.get("SUITE_INIT_CKPT")
|
|
553
|
+
if init_ck:
|
|
554
|
+
_ck = torch.load(init_ck, map_location="cuda")
|
|
555
|
+
assert ("latent_task" in _ck) == bool(getattr(algo, "ltask", False)), (
|
|
556
|
+
f"{init_ck}: a latent task-phase checkpoint resumes only with DN_LATENT_TASK=1, and that run only from one")
|
|
557
|
+
algo.actor.load_state_dict(_ck["actor"])
|
|
558
|
+
_r = _ck["obs_rms"]
|
|
559
|
+
algo.obs_rms.mean, algo.obs_rms.var, algo.obs_rms.count = _r["mean"], _r["var"], _r["count"]
|
|
560
|
+
_extra = []
|
|
561
|
+
if getattr(algo, "latent", None) is not None:
|
|
562
|
+
algo.load_latent_state(_ck); _extra.append("latent+ref_rms")
|
|
563
|
+
elif getattr(algo, "ltask", False):
|
|
564
|
+
algo.load_latent_task_state(_ck); _extra.append("latent_task (frozen model verified)")
|
|
565
|
+
else:
|
|
566
|
+
assert "latent" not in _ck, f"{init_ck} is a latent-model checkpoint; set DN_LATENT=1 to resume it"
|
|
567
|
+
if "critic" in _ck and hasattr(algo, "critic"):
|
|
568
|
+
algo.critic.load_state_dict(_ck["critic"]); _extra.append("critic")
|
|
569
|
+
if "log_alpha" in _ck and hasattr(algo, "log_alpha"):
|
|
570
|
+
with torch.no_grad():
|
|
571
|
+
algo.log_alpha.copy_(_ck["log_alpha"].to(algo.log_alpha.device))
|
|
572
|
+
_extra.append("log_alpha")
|
|
573
|
+
# Restore the ADAM optimizer state (1st/2nd-moment buffers) so the resume is not a cold-Adam start
|
|
574
|
+
# (which perturbs the converged policy for the first ~epochs). Present only in ckpts saved after
|
|
575
|
+
# this feature; a critic-less/opt-less ckpt still warm-starts on the weights.
|
|
576
|
+
# load_state_dict also restores each param group's lr from the ckpt, which silently overrode the
|
|
577
|
+
# configured lr (SAPO_ALPHA_LR=0 still moved alpha 0.10 -> 0.45 on 2026-10-13: the alpha lr is not
|
|
578
|
+
# scheduled, so the ckpt's 5e-3 stayed). The constructor's lr wins; under the default linear schedule
|
|
579
|
+
# the actor / critic lrs are rewritten at the top of every epoch anyway, and an unset alpha knob equals
|
|
580
|
+
# the ckpt's lr, so default runs are unchanged.
|
|
581
|
+
for _oname in ("actor_opt", "critic_opt", "alpha_opt"):
|
|
582
|
+
if _oname in _ck and hasattr(algo, _oname):
|
|
583
|
+
_opt = getattr(algo, _oname); _lr0 = [g["lr"] for g in _opt.param_groups]
|
|
584
|
+
_opt.load_state_dict(_ck[_oname])
|
|
585
|
+
for _g, _lr in zip(_opt.param_groups, _lr0):
|
|
586
|
+
_g["lr"] = _lr
|
|
587
|
+
_extra.append(_oname)
|
|
588
|
+
# CONTINUE the LR-anneal schedule from where the ckpt left off. Without this, the linear anneal
|
|
589
|
+
# restarts at the fresh PEAK lr (2e-3) and hammers the already-converged policy -> the warm-start
|
|
590
|
+
# perf dip. epoch_offset shifts the anneal frac so the continuation resumes at the ckpt's annealed
|
|
591
|
+
# lr and keeps annealing (== training as if it had planned prev+current epochs from the start).
|
|
592
|
+
if _ck.get("epoch"):
|
|
593
|
+
algo.epoch_offset = int(_ck["epoch"]); _extra.append(f"epoch_offset={algo.epoch_offset}")
|
|
594
|
+
# Opt-in: CONTINUE the env's own schedules too (the TASKWALK_W_* ramps, the fall gate, the speed
|
|
595
|
+
# curricula). They count control steps in `env._train_steps`, which a warm start leaves at 0, so a
|
|
596
|
+
# continuation of a scheduled run restarts every ramp: its scheduled terms train at their start weight
|
|
597
|
+
# for _AFTER and below full weight for _STEPS (found 2026-10-16: five regularisers of the kickstarted
|
|
598
|
+
# line at 0 for the first 200 epochs of its continuations). Off by default, because an imitation
|
|
599
|
+
# pad's epoch is no position in a taskwalk schedule.
|
|
600
|
+
if os.environ.get("SUITE_INIT_RESUME_ENV_STEPS", "0") == "1":
|
|
601
|
+
assert _ck.get("epoch") and hasattr(env, "_train_steps"), \
|
|
602
|
+
"SUITE_INIT_RESUME_ENV_STEPS needs a ckpt with its epoch and an env that counts _train_steps"
|
|
603
|
+
assert not getattr(algo, "adaptive_horizon", False), "an adaptive horizon has no fixed steps per epoch"
|
|
604
|
+
env._train_steps = int(_ck["epoch"]) * int(algo.steps_num)
|
|
605
|
+
_extra.append(f"env_train_steps={env._train_steps}")
|
|
606
|
+
if getattr(env, "_tw_w_sched", None):
|
|
607
|
+
env._tw_advance_w_sched()
|
|
608
|
+
print("[warmstart] scheduled weights at the resumed step: " + ", ".join(
|
|
609
|
+
f"{_n} {getattr(env.taskwalk, _n):.4g}" for _n, *_ in env._tw_w_sched), flush=True)
|
|
610
|
+
print(f"[warmstart] loaded actor+obs_rms{'+' + '+'.join(_extra) if _extra else ''} "
|
|
611
|
+
f"from {init_ck} (ep{_ck.get('epoch')})", flush=True)
|
|
612
|
+
write_run_config(out_dir, env, algo, env_name, algo_name, cfg, seed)
|
|
613
|
+
log = []
|
|
614
|
+
# SUITE_CKPT_AT_WALL_S (comma-separated seconds of training wall clock): for each, one extra logged and saved
|
|
615
|
+
# epoch, the last one that ends at or just before it (judged by the length of the epoch before), so cells of
|
|
616
|
+
# different speed have a checkpoint at the same training time. Unset = off.
|
|
617
|
+
_at_wall = sorted(float(x) for x in os.environ.get("SUITE_CKPT_AT_WALL_S", "").split(",") if x)
|
|
618
|
+
_wall_prev = [0.0]
|
|
619
|
+
t0 = time.time()
|
|
620
|
+
|
|
621
|
+
def callback(epoch, step_count, ret, value_loss, grad_norm):
|
|
622
|
+
_now = time.time() - t0
|
|
623
|
+
_at = bool(_at_wall) and _now + (_now - _wall_prev[0]) > _at_wall[0]
|
|
624
|
+
while _at_wall and _now + (_now - _wall_prev[0]) > _at_wall[0]:
|
|
625
|
+
_at_wall.pop(0)
|
|
626
|
+
_wall_prev[0] = _now
|
|
627
|
+
# The final epoch is always a logged epoch: the checkpoint save below runs only on logged epochs, and when
|
|
628
|
+
# cfg.epochs is not a multiple of the interval (a 680-epoch resume logs every 13) the last epoch was never saved.
|
|
629
|
+
if _at or epoch == 0 or (epoch + 1) % max(1, cfg.epochs // 50) == 0 or epoch + 1 == cfg.epochs:
|
|
630
|
+
elapsed = time.time() - t0
|
|
631
|
+
monitor = getattr(env, "last_monitor", {})
|
|
632
|
+
# Eval-free BEHAVIORAL indicators (training return alone can't tell "escaped/walking" from
|
|
633
|
+
# "passive-near-ref crept up"): mean muscle activation (passive rest ~0.05 vs active >0.1) and
|
|
634
|
+
# mean episode length (sink-terminates short vs holds long). Read straight from the env state.
|
|
635
|
+
act_mean = float(env.a.mean()) if hasattr(env, "a") and env.a is not None else 0.0
|
|
636
|
+
ep_len_mean = float(env.progress.float().mean()) if hasattr(env, "progress") else 0.0
|
|
637
|
+
log.append(
|
|
638
|
+
dict(
|
|
639
|
+
epoch=epoch + 1,
|
|
640
|
+
step_count=int(step_count),
|
|
641
|
+
train_return_proxy=float(ret),
|
|
642
|
+
value_loss=float(value_loss),
|
|
643
|
+
grad_norm=float(grad_norm),
|
|
644
|
+
act_mean=act_mean,
|
|
645
|
+
ep_len_mean=ep_len_mean,
|
|
646
|
+
raw_action_grad_max=float(getattr(algo, "last_raw_action_grad_max", 0.0)),
|
|
647
|
+
raw_action_grad_nonfinite=bool(getattr(algo, "last_raw_action_grad_nonfinite", False)),
|
|
648
|
+
entropy_alpha=float(getattr(algo, "last_alpha", 0.0)), # SAPO auto-temperature (0 for non-SAPO)
|
|
649
|
+
entropy_mean=float(getattr(algo, "last_entropy_mean", 0.0)), # SAPO mean policy entropy (0 for non-SAPO)
|
|
650
|
+
wall_s=float(elapsed),
|
|
651
|
+
control_steps_per_s=float(step_count / max(elapsed, 1e-9)),
|
|
652
|
+
**{f"monitor_{k}": float(v) for k, v in monitor.items()},
|
|
653
|
+
# IM_V2's ADAPTIVE STATE (alpha_g, s_j, E_ema). Without this a run leaves no record of
|
|
654
|
+
# how its own reward re-scaled itself: the fb_v9_imv2 6000-epoch run finished with the
|
|
655
|
+
# whole s/alpha history unrecoverable -- state() existed and was never called, the
|
|
656
|
+
# checkpoints carry only actor/critic/obs_rms, and the log's `alpha` field is SAPO's
|
|
657
|
+
# entropy temperature, not alpha_g. Cheap (a few floats per LOG epoch, not per step)
|
|
658
|
+
# and it is what makes the beta A/B readable.
|
|
659
|
+
**_v2_log_fields(env),
|
|
660
|
+
# the latent skill model (DN_LATENT only): window-mean KL(q || p) per step, its weight, the
|
|
661
|
+
# encoder's pre-clip grad norm
|
|
662
|
+
**({"latent_kl_mean": float(algo.last_kl_mean), "latent_beta": float(algo.last_beta),
|
|
663
|
+
"latent_grad_norm": float(algo.last_latent_gn)}
|
|
664
|
+
if getattr(algo, "latent", None) is not None else {}),
|
|
665
|
+
# its task phase (DN_LATENT_TASK only): window-mean w_z ||mu_g||^2 per step, the offset's rms per
|
|
666
|
+
# z dim, and the env's heading error (deg), speed error (m/s) and L_g over the epoch's steps
|
|
667
|
+
**({"latent_task_reg": float(algo.last_task_reg_mean),
|
|
668
|
+
"latent_task_offset_rms": float(algo.last_task_offset_rms),
|
|
669
|
+
**{f"latent_task_{k}": float(v) for k, v in algo.last_task_stats.items()}}
|
|
670
|
+
if getattr(algo, "ltask", False) else {}),
|
|
671
|
+
)
|
|
672
|
+
)
|
|
673
|
+
monitor_text = ""
|
|
674
|
+
if monitor:
|
|
675
|
+
monitor_text = (
|
|
676
|
+
f" cpen={monitor['contact_pen_max']:.4f}"
|
|
677
|
+
f" jpen={monitor['joint_limit_pen_max']:.4f}"
|
|
678
|
+
)
|
|
679
|
+
alpha_text = ""
|
|
680
|
+
if hasattr(algo, "last_alpha"): # SAPO auto-temperature tracking
|
|
681
|
+
alpha_text = f" alpha={algo.last_alpha:.4f} entH={getattr(algo, 'last_entropy_mean', 0.0):+.3f}"
|
|
682
|
+
if getattr(algo, "decision_every", 1) > 1: # PREREG_S290 Amendment 16: the share of decision steps in the window (0.5 at k 2)
|
|
683
|
+
alpha_text += f" dec={float(algo.dec_buf.mean()):.3f}" # read at the log line (one sync, as the line's other floats)
|
|
684
|
+
if getattr(algo, "adaptive_horizon", False): # AHAC adaptive rollout length
|
|
685
|
+
alpha_text += f" H={getattr(algo, 'last_H', 0.0):.1f}"
|
|
686
|
+
if getattr(algo, "per_env_cut", False): # per-env AHAC cut: fraction of (step x env) truncated
|
|
687
|
+
alpha_text += f" cut={getattr(algo, 'last_cut_frac', 0.0):.3f}"
|
|
688
|
+
if getattr(algo, "latent", None) is not None: # latent skill model: KL per step, its weight, encoder gn
|
|
689
|
+
alpha_text += f" kl={algo.last_kl_mean:.3f} beta={algo.last_beta:.4g} lgn={algo.last_latent_gn:.3f}"
|
|
690
|
+
if getattr(algo, "ltask", False): # its task phase: regulariser, offset rms, task errors
|
|
691
|
+
_ts = algo.last_task_stats
|
|
692
|
+
alpha_text += (f" reg={algo.last_task_reg_mean:.4f} off={algo.last_task_offset_rms:.4f}"
|
|
693
|
+
f" dth={_ts.get('heading_err_deg', 0.0):.1f}deg dv={_ts.get('speed_err', 0.0):.3f}")
|
|
694
|
+
if getattr(env, "musclepd", None) is not None: # MuscleVAE's PD action: muscle-substeps passing no gradient
|
|
695
|
+
_pd = env.pop_pd_stats()
|
|
696
|
+
alpha_text += f" pd0={_pd['pd_zero']:.3f} Alo={_pd['A_lo']:.3f} Ahi={_pd['A_hi']:.3f}"
|
|
697
|
+
_it = getattr(env, "imitation_task", None)
|
|
698
|
+
if _it is not None and getattr(_it, "IM_RECON", ""): # MuscleVAE's pose_err per env-step: sum, then its six terms
|
|
699
|
+
_rc = _it.pop_recon_stats()
|
|
700
|
+
alpha_text += f" rcL={_rc['L']:.3f} rc=" + "/".join(f"{_rc[k]:.3f}" for k in ("pos", "rot", "vel", "avel", "height", "up_dir"))
|
|
701
|
+
print(
|
|
702
|
+
f"[{env_name}/{algo_name}] ep={epoch + 1:4d}/{cfg.epochs} "
|
|
703
|
+
f"steps={step_count:9d} ret={ret:9.3f} vloss={value_loss:9.3f} "
|
|
704
|
+
f"gn={grad_norm:8.3f} act={act_mean:6.3f} eplen={ep_len_mean:6.1f} "
|
|
705
|
+
f"{step_count / max(elapsed, 1e-9):8.0f} ctrl-steps/s{monitor_text}{alpha_text}",
|
|
706
|
+
flush=True,
|
|
707
|
+
)
|
|
708
|
+
# Periodic checkpoint (env-var gated, cheap) so a FAIR reward-vs-samples curve can be built
|
|
709
|
+
# OFFLINE after training (deterministic eval per ckpt) -- no inline-eval slowdown of training.
|
|
710
|
+
# SUITE_SAVE_CKPTS_EVERY (epochs, 0 = every logged epoch): a 2000-epoch full-body run otherwise writes 50
|
|
711
|
+
# checkpoints, ~1.4 GB (the neu disk filled on them 2026-10-11). The final epoch is always kept.
|
|
712
|
+
_every = int(os.environ.get("SUITE_SAVE_CKPTS_EVERY", "0"))
|
|
713
|
+
assert _every == 0 or _every % max(1, cfg.epochs // 50) == 0, (
|
|
714
|
+
f"SUITE_SAVE_CKPTS_EVERY={_every} must be a multiple of the log interval {max(1, cfg.epochs // 50)}")
|
|
715
|
+
_keep = _at or _every == 0 or (epoch + 1) % _every == 0 or epoch + 1 == cfg.epochs
|
|
716
|
+
if os.environ.get("SUITE_SAVE_CKPTS") and _keep and hasattr(algo, "actor") and hasattr(algo, "obs_rms"):
|
|
717
|
+
ck = out_dir / "ckpt"
|
|
718
|
+
ck.mkdir(exist_ok=True)
|
|
719
|
+
torch.save(ckpt_payload(algo, step_count, epoch + 1), ck / f"{env_name}_{algo_name}_ep{epoch + 1:04d}.pt")
|
|
720
|
+
# PARTIAL per-epoch log, at every LOGGED epoch (not gated on SUITE_SAVE_CKPTS -- the diagnostics
|
|
721
|
+
# are worth keeping even for a run that saves no checkpoints). The full record is only assembled
|
|
722
|
+
# when train_one RETURNS, so until then the whole per-epoch history -- 135 v3_* fields per row on
|
|
723
|
+
# the imitation path -- lives in this process's memory and nowhere else. On an 18 h run that means
|
|
724
|
+
# a crash at hour 17 loses all of it, and it means the run cannot be inspected WHILE it runs, which
|
|
725
|
+
# is the same hole that left fb_v9_imv2's reward history unrecoverable. stdout is no substitute: it
|
|
726
|
+
# is block-buffered through a pipe and carries none of the v3_* fields.
|
|
727
|
+
# Cheap (one ~200 KB dump per logged epoch) and rewritten each time, so the newest is always
|
|
728
|
+
# complete; `complete: False` marks it as superseded by the final file train_one writes.
|
|
729
|
+
(out_dir / f"{env_name}_{algo_name}_partial.json").write_text(
|
|
730
|
+
json.dumps({"epoch": epoch + 1, "epochs": cfg.epochs, "complete": False, "log": log}))
|
|
731
|
+
|
|
732
|
+
algo.train(callback=callback)
|
|
733
|
+
torch.cuda.synchronize()
|
|
734
|
+
wall = time.time() - t0
|
|
735
|
+
eval_env = make_env(env_name, cfg, seed + 12345, stochastic_init=False)
|
|
736
|
+
npz_path = out_dir / f"{env_name}_{algo_name}_eval.npz"
|
|
737
|
+
metrics = eval_and_record(env_name, eval_env, algo, npz_path)
|
|
738
|
+
# The algorithm's own count: cfg.steps_num is the config default, which DN_STEPS_NUM (and SAPO's adaptive horizon)
|
|
739
|
+
# override, so epochs x cfg.steps_num x n_env overstated a 24-step window's throughput by 32 / 24 (rep4x, 10-28).
|
|
740
|
+
total_steps = int(getattr(algo, "step_count", cfg.epochs * cfg.steps_num * cfg.n_env))
|
|
741
|
+
result = dict(
|
|
742
|
+
env=env_name,
|
|
743
|
+
algo=algo_name,
|
|
744
|
+
n_env=cfg.n_env,
|
|
745
|
+
epochs=cfg.epochs,
|
|
746
|
+
steps_num=int(getattr(algo, "steps_num", cfg.steps_num)),
|
|
747
|
+
substeps=cfg.substeps,
|
|
748
|
+
episode_length=cfg.episode_length,
|
|
749
|
+
train_wall_s=wall,
|
|
750
|
+
train_control_steps=total_steps,
|
|
751
|
+
train_control_steps_per_s=total_steps / wall,
|
|
752
|
+
log=log,
|
|
753
|
+
**metrics,
|
|
754
|
+
)
|
|
755
|
+
(out_dir / f"{env_name}_{algo_name}.json").write_text(json.dumps(result, indent=2))
|
|
756
|
+
print(
|
|
757
|
+
f"[{env_name}/{algo_name}] DONE wall={wall:.1f}s throughput={total_steps / wall:.0f} ctrl-steps/s "
|
|
758
|
+
f"eval_steps={metrics['eval_steps']} fwd={metrics['eval_fwd']:.3f} ret={metrics['eval_return']:.3f}",
|
|
759
|
+
flush=True,
|
|
760
|
+
)
|
|
761
|
+
return result
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
def train_suite(args):
|
|
765
|
+
assert torch.cuda.is_available()
|
|
766
|
+
out_dir = pathlib.Path(args.out_dir)
|
|
767
|
+
out_dir.mkdir(parents=True, exist_ok=True)
|
|
768
|
+
envs = [x for x in args.envs.split(",") if x]
|
|
769
|
+
algos = [x for x in args.algos.split(",") if x]
|
|
770
|
+
rows = []
|
|
771
|
+
for env_name in envs:
|
|
772
|
+
assert env_name in DEFAULT_CONFIGS, env_name
|
|
773
|
+
cfg = override_config(DEFAULT_CONFIGS[env_name], args, env_name)
|
|
774
|
+
for algo_name in algos:
|
|
775
|
+
assert algo_name == "sapo", algo_name
|
|
776
|
+
rows.append(train_one(env_name, algo_name, cfg, out_dir, args.seed))
|
|
777
|
+
write_summary(out_dir, rows)
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
def override_config(cfg: EnvConfig, args, env_name: str) -> EnvConfig:
|
|
781
|
+
epochs = args.epochs if args.epochs > 0 else cfg.epochs
|
|
782
|
+
n_env = args.n_env if args.n_env > 0 else cfg.n_env
|
|
783
|
+
steps_num = args.steps_num if args.steps_num > 0 else cfg.steps_num
|
|
784
|
+
substeps = args.substeps if args.substeps > 0 else cfg.substeps
|
|
785
|
+
if args.profile == "smoke":
|
|
786
|
+
epochs = min(epochs, 20)
|
|
787
|
+
n_env = min(n_env, 128)
|
|
788
|
+
steps_num = min(steps_num, 8)
|
|
789
|
+
action_grad_clip = cfg.action_grad_clip
|
|
790
|
+
return EnvConfig(
|
|
791
|
+
n_env=n_env,
|
|
792
|
+
epochs=epochs,
|
|
793
|
+
steps_num=steps_num,
|
|
794
|
+
episode_length=cfg.episode_length,
|
|
795
|
+
actor_bias=cfg.actor_bias,
|
|
796
|
+
substeps=substeps,
|
|
797
|
+
action_grad_clip=action_grad_clip,
|
|
798
|
+
)
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
def write_summary(out_dir: pathlib.Path, rows: list[dict]):
|
|
802
|
+
with (out_dir / "summary.csv").open("w", newline="") as f:
|
|
803
|
+
fields = [
|
|
804
|
+
"env",
|
|
805
|
+
"algo",
|
|
806
|
+
"n_env",
|
|
807
|
+
"epochs",
|
|
808
|
+
"steps_num",
|
|
809
|
+
"substeps",
|
|
810
|
+
"train_wall_s",
|
|
811
|
+
"train_control_steps",
|
|
812
|
+
"train_control_steps_per_s",
|
|
813
|
+
"eval_steps",
|
|
814
|
+
"eval_fwd",
|
|
815
|
+
"eval_return",
|
|
816
|
+
"eval_height_mean",
|
|
817
|
+
"rollout_dnrec",
|
|
818
|
+
]
|
|
819
|
+
writer = csv.DictWriter(f, fieldnames=fields)
|
|
820
|
+
writer.writeheader()
|
|
821
|
+
for row in rows:
|
|
822
|
+
writer.writerow({k: row[k] for k in fields})
|
|
823
|
+
(out_dir / "summary.json").write_text(json.dumps(rows, indent=2))
|
|
824
|
+
write_report(out_dir, rows)
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
def write_report(out_dir: pathlib.Path, rows: list[dict]):
|
|
828
|
+
lines = [
|
|
829
|
+
"# RL Algorithm Suite",
|
|
830
|
+
"",
|
|
831
|
+
"GPU vector training with `SapoVec` on the full-body muscle environment.",
|
|
832
|
+
"Throughput is control-steps/s, measured as `epochs * steps_num * n_env / train_wall_s`.",
|
|
833
|
+
"",
|
|
834
|
+
"| env | algo | n_env | epochs | steps_num | substeps | wall s | ctrl-steps/s | eval steps | eval fwd | eval return |",
|
|
835
|
+
"|---|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|",
|
|
836
|
+
]
|
|
837
|
+
for r in rows:
|
|
838
|
+
lines.append(
|
|
839
|
+
f"| {r['env']} | {r['algo']} | {r['n_env']} | {r['epochs']} | {r['steps_num']} | {r['substeps']} | "
|
|
840
|
+
f"{r['train_wall_s']:.1f} | {r['train_control_steps_per_s']:.0f} | "
|
|
841
|
+
f"{r['eval_steps']} | {r['eval_fwd']:.3f} | {r['eval_return']:.3f} |"
|
|
842
|
+
)
|
|
843
|
+
lines += ["", "Videos are generated by `python -m diffneusim.train.rl_algorithm_suite render --out-dir <run-dir>`."]
|
|
844
|
+
(out_dir / "report.md").write_text("\n".join(lines) + "\n")
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
def run_to_mp4(dnrec: pathlib.Path, mp4: pathlib.Path):
|
|
848
|
+
subprocess.run(
|
|
849
|
+
[
|
|
850
|
+
sys.executable, "-m", "diffneusim.viz.to_mp4",
|
|
851
|
+
str(dnrec),
|
|
852
|
+
str(mp4),
|
|
853
|
+
"--w",
|
|
854
|
+
"960",
|
|
855
|
+
"--h",
|
|
856
|
+
"640",
|
|
857
|
+
"--fps",
|
|
858
|
+
"30",
|
|
859
|
+
"--no-shadow",
|
|
860
|
+
"--samples",
|
|
861
|
+
"0",
|
|
862
|
+
],
|
|
863
|
+
cwd=str(ROOT),
|
|
864
|
+
check=True,
|
|
865
|
+
)
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
def render_suite(args):
|
|
869
|
+
out_dir = pathlib.Path(args.out_dir)
|
|
870
|
+
assert out_dir.exists(), out_dir
|
|
871
|
+
rendered = []
|
|
872
|
+
# The eval writes a self-contained .dnrec (rl_env_render's build_from_dnmodel) -> render every one through
|
|
873
|
+
# the ONE .dnrec -> mp4 path.
|
|
874
|
+
for dnrec_path in sorted(out_dir.glob("*_eval.dnrec")):
|
|
875
|
+
stem = dnrec_path.stem
|
|
876
|
+
env_name, algo = stem.rsplit("_", 2)[0], stem.rsplit("_", 2)[1]
|
|
877
|
+
mp4 = out_dir / f"{stem}.mp4"
|
|
878
|
+
run_to_mp4(dnrec_path, mp4)
|
|
879
|
+
rendered.append((env_name, algo, str(mp4)))
|
|
880
|
+
print(f"RENDERED {env_name}/{algo}: {mp4}", flush=True)
|
|
881
|
+
append_render_report(out_dir, rendered)
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
def append_render_report(out_dir: pathlib.Path, rendered):
|
|
885
|
+
report = out_dir / "report.md"
|
|
886
|
+
text = report.read_text() if report.exists() else "# RL Algorithm Suite\n"
|
|
887
|
+
lines = [text.rstrip(), "", "## Videos", ""]
|
|
888
|
+
for env, algo, path in rendered:
|
|
889
|
+
rel = pathlib.Path(path).relative_to(out_dir)
|
|
890
|
+
lines.append(f"- `{env}/{algo}`: `{rel}`")
|
|
891
|
+
report.write_text("\n".join(lines) + "\n")
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
def main():
|
|
895
|
+
parser = argparse.ArgumentParser()
|
|
896
|
+
sub = parser.add_subparsers(dest="cmd", required=True)
|
|
897
|
+
train = sub.add_parser("train")
|
|
898
|
+
train.add_argument("--out-dir", required=True)
|
|
899
|
+
train.add_argument("--envs", default="fullbody")
|
|
900
|
+
train.add_argument("--algos", default="sapo")
|
|
901
|
+
train.add_argument("--seed", type=int, default=1)
|
|
902
|
+
train.add_argument("--profile", choices=("default", "smoke"), default="default")
|
|
903
|
+
train.add_argument("--epochs", type=int, default=0, help="override all env epoch defaults when >0")
|
|
904
|
+
train.add_argument("--n-env", type=int, default=0, help="override all env n_env defaults when >0")
|
|
905
|
+
train.add_argument("--steps-num", type=int, default=0, help="override all env horizon defaults when >0")
|
|
906
|
+
train.add_argument("--substeps", type=int, default=0, help="override all env physics substep defaults when >0")
|
|
907
|
+
render = sub.add_parser("render")
|
|
908
|
+
render.add_argument("--out-dir", required=True)
|
|
909
|
+
args = parser.parse_args()
|
|
910
|
+
if args.cmd == "train":
|
|
911
|
+
train_suite(args)
|
|
912
|
+
else:
|
|
913
|
+
render_suite(args)
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
if __name__ == "__main__":
|
|
917
|
+
main()
|