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,599 @@
|
|
|
1
|
+
"""SHAC networks ported from DiffRL (Xu et al. 2022) -- a faithful mirror, not a reinvention.
|
|
2
|
+
|
|
3
|
+
ActorStochasticMLP (learned per-action logstd = the EXPLORATION our prior deterministic actor
|
|
4
|
+
lacked), CriticMLP, and RunningMeanStd (obs normalization). Hidden layers are Linear + elu +
|
|
5
|
+
LayerNorm; the actor's reparameterized rsample() keeps actions differentiable so the SHAC policy
|
|
6
|
+
gradient flows through the differentiable sim. The CRITIC linears use orthogonal init (gain
|
|
7
|
+
sqrt(2), bias 0); the ACTOR uses PyTorch default init -- matching DiffRL, whose ActorStochasticMLP
|
|
8
|
+
DEFINES an orthogonal init_ but never applies it to its Linears (only the critic + the deterministic
|
|
9
|
+
actor do). [An earlier commit wrongly made the actor orthogonal "to match DiffRL"; this reverts it.]
|
|
10
|
+
|
|
11
|
+
Reference: physics-review/DiffRL/models/{actor,critic}.py + utils/running_mean_std.py.
|
|
12
|
+
"""
|
|
13
|
+
import math
|
|
14
|
+
|
|
15
|
+
import numpy as np
|
|
16
|
+
import torch
|
|
17
|
+
import torch.distributions as D
|
|
18
|
+
import torch.nn as nn
|
|
19
|
+
import torch.nn.functional as F
|
|
20
|
+
from torch.distributions.normal import Normal
|
|
21
|
+
|
|
22
|
+
_ACT = {"elu": nn.ELU, "relu": nn.ReLU, "tanh": nn.Tanh, "silu": nn.SiLU}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class _LatticeDist:
|
|
26
|
+
"""State-independent Lattice exploration (Chiappa et al. 2023, arXiv:2305.20065) as a LOW-RANK
|
|
27
|
+
Gaussian N(mu, Sigma), Sigma = diag(sa^2) + W diag(sx^2) W^T, WITHOUT ever forming or factorizing
|
|
28
|
+
the dense (A,A) covariance. Every Gaussian quantity (log_prob / entropy / KL) is routed through
|
|
29
|
+
the (H,H) Woodbury capacitance C = diag(1/sx^2) + W^T diag(1/sa^2) W, where H = latent width << A
|
|
30
|
+
(416 vs ~512 at full body). Cost/memory are O(A*H + H^3) instead of the dense O(A^3), and there is
|
|
31
|
+
no per-step (A,A) Cholesky (the dense version's full-body OOM / 298-steps/s wall). Sigma is shared
|
|
32
|
+
across the batch (state-independent), so C is factorized ONCE per distribution. A tiny jitter is
|
|
33
|
+
folded into sa^2 for PSD stability (mirrors the old dense _lattice_cov). Shapes: mu (B,A); sa (A,);
|
|
34
|
+
sx (H,); W (A,H) = the policy's final linear (its emergent actuator synergies)."""
|
|
35
|
+
|
|
36
|
+
_JITTER = 1e-6
|
|
37
|
+
|
|
38
|
+
def __init__(self, mu, sa, sx, W):
|
|
39
|
+
self.loc = mu # (B,A) mean
|
|
40
|
+
self.sa = sa # (A,) action-space std
|
|
41
|
+
self.sx = sx # (H,) latent std
|
|
42
|
+
self.W = W # (A,H) mean-layer weight (synergy basis)
|
|
43
|
+
self.A = int(W.shape[0])
|
|
44
|
+
self.H = int(W.shape[1])
|
|
45
|
+
self._sa2 = sa * sa + self._JITTER # (A,) effective diagonal variance
|
|
46
|
+
self._sx2 = sx * sx # (H,)
|
|
47
|
+
self._ea = None # last-drawn action noise (B,A)
|
|
48
|
+
self._ex = None # last-drawn latent noise (B,H)
|
|
49
|
+
self._cache = None # (Lc, logdetSigma), shared covariance
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def mean(self):
|
|
53
|
+
return self.loc
|
|
54
|
+
|
|
55
|
+
def _capacitance(self):
|
|
56
|
+
"""C = diag(1/sx^2) + W^T diag(1/sa^2) W (H,H), its lower Cholesky Lc, and log|Sigma| via the
|
|
57
|
+
matrix-determinant lemma (log|D| + log|Lambda| + log|C|). Shared cov => computed once, cached."""
|
|
58
|
+
if self._cache is None:
|
|
59
|
+
C = torch.diag(1.0 / self._sx2) + self.W.t() @ (self.W / self._sa2[:, None]) # (H,H)
|
|
60
|
+
Lc = torch.linalg.cholesky(C)
|
|
61
|
+
logdet = (self._sa2.log().sum() + self._sx2.log().sum()
|
|
62
|
+
+ 2.0 * torch.diagonal(Lc).log().sum())
|
|
63
|
+
self._cache = (Lc, logdet)
|
|
64
|
+
return self._cache
|
|
65
|
+
|
|
66
|
+
def rsample(self):
|
|
67
|
+
a, _, _ = self.rsample_with_noise()
|
|
68
|
+
return a
|
|
69
|
+
|
|
70
|
+
def rsample_with_noise(self):
|
|
71
|
+
"""Reparameterized draw a = mu + sa*ea + (sx*ex) W^T, ea~N(0,I_A), ex~N(0,I_H). NO Cholesky.
|
|
72
|
+
Returns (a, ea, ex) and stashes (ea,ex) so a caller can cache the exact noise realization for
|
|
73
|
+
the pathwise sample-reuse surrogate."""
|
|
74
|
+
mu = self.loc
|
|
75
|
+
ea = torch.randn_like(mu) # (B,A)
|
|
76
|
+
ex = torch.randn(mu.shape[0], self.H, dtype=mu.dtype, device=mu.device) # (B,H)
|
|
77
|
+
a = mu + self.sa * ea + (self.sx * ex) @ self.W.t()
|
|
78
|
+
self._ea, self._ex = ea, ex
|
|
79
|
+
return a, ea, ex
|
|
80
|
+
|
|
81
|
+
def log_prob(self, a):
|
|
82
|
+
"""log N(a; mu, Sigma) via Woodbury; NEVER forms (A,A). r = a-mu (B,A)."""
|
|
83
|
+
Lc, logdet = self._capacitance()
|
|
84
|
+
r = a - self.loc # (B,A)
|
|
85
|
+
t = self.W.t() @ (r / self._sa2).t() # (H,B) = W^T D^-1 r
|
|
86
|
+
v = torch.cholesky_solve(t, Lc) # (H,B) = C^-1 t
|
|
87
|
+
maha = (r * r / self._sa2).sum(-1) - (t * v).sum(0) # (B,) r^T Sigma^-1 r
|
|
88
|
+
return -0.5 * (maha + logdet + self.A * math.log(2.0 * math.pi)) # (B,)
|
|
89
|
+
|
|
90
|
+
def entropy(self):
|
|
91
|
+
_, logdet = self._capacitance()
|
|
92
|
+
return 0.5 * (self.A * (1.0 + math.log(2.0 * math.pi)) + logdet) # scalar (shared cov)
|
|
93
|
+
|
|
94
|
+
def kl_old_new(self, old, mu_o):
|
|
95
|
+
"""KL( N(mu_o, So) || self ): OLD (behavior) dist vs this NEW dist. `old` is a detached
|
|
96
|
+
_LatticeDist holding (sa_o, sx_o, W_o); mu_o (B,A) is the cached behavior mean. All work is
|
|
97
|
+
(H,H)/(H,A); NEVER an (A,A) tensor. Differentiable in the new dist; old detached.
|
|
98
|
+
KL = 0.5[ tr(Sn^-1 So) + (mu_n-mu_o)^T Sn^-1 (mu_n-mu_o) - A + log|Sn| - log|So| ]."""
|
|
99
|
+
Lcn, logdet_n = self._capacitance()
|
|
100
|
+
_, logdet_o = old._capacitance()
|
|
101
|
+
san2, Wn = self._sa2, self.W
|
|
102
|
+
sao2, sxo2, Wo = old._sa2, old._sx2, old.W
|
|
103
|
+
# quadratic term via the Woodbury Mahalanobis of the NEW dist at r = mu_n - mu_o
|
|
104
|
+
r = self.loc - mu_o # (B,A)
|
|
105
|
+
t = Wn.t() @ (r / san2).t() # (H,B)
|
|
106
|
+
v = torch.cholesky_solve(t, Lcn)
|
|
107
|
+
quad = (r * r / san2).sum(-1) - (t * v).sum(0) # (B,)
|
|
108
|
+
# tr(Sn^-1 Do) with Sn^-1 = Dn^-1 - Dn^-1 Wn Cn^-1 Wn^T Dn^-1
|
|
109
|
+
Y = torch.cholesky_solve(Wn.t(), Lcn) # (H,A) = Cn^-1 Wn^T
|
|
110
|
+
diag_WCW = (Wn * Y.t()).sum(1) # (A,) diag(Wn Cn^-1 Wn^T)
|
|
111
|
+
term_Do = (sao2 * (1.0 / san2 - diag_WCW / (san2 * san2))).sum() # scalar
|
|
112
|
+
# tr(Sn^-1 Wo Lambda_o Wo^T) = sum sxo^2 * diag(Wo^T Sn^-1 Wo)
|
|
113
|
+
P = Wo.t() @ (Wo / san2[:, None]) # (H,H) = Wo^T Dn^-1 Wo
|
|
114
|
+
Q = Wn.t() @ (Wo / san2[:, None]) # (H,H) = Wn^T Dn^-1 Wo
|
|
115
|
+
WoSnInvWo = P - Q.t() @ torch.cholesky_solve(Q, Lcn) # (H,H) = Wo^T Sn^-1 Wo
|
|
116
|
+
term_Wo = (sxo2 * torch.diagonal(WoSnInvWo)).sum() # scalar
|
|
117
|
+
tr = term_Do + term_Wo
|
|
118
|
+
return 0.5 * (tr + quad - self.A + logdet_n - logdet_o) # (B,)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _mlp(dims, activation, orthogonal, plain_last=True):
|
|
122
|
+
# dims = [in, h1, ..., out]; hidden layers get activation + LayerNorm (DiffRL structure).
|
|
123
|
+
# plain_last=True (default): the final linear is bare (no act/LayerNorm) -- the ShacVec/RpoVec
|
|
124
|
+
# convention (mu_net / critic head), byte-identical. plain_last=False: EVERY linear (incl. the last)
|
|
125
|
+
# gets act+LayerNorm -- used for SAPO's ActorSquashedMLP shared feature trunk, whose units[-1] output
|
|
126
|
+
# feeds the mu/logstd heads with activation+norm already applied (mirrors mineral MLP plain_last=False).
|
|
127
|
+
act = _ACT[activation]
|
|
128
|
+
mods = []
|
|
129
|
+
for i in range(len(dims) - 1):
|
|
130
|
+
lin = nn.Linear(dims[i], dims[i + 1])
|
|
131
|
+
if orthogonal:
|
|
132
|
+
nn.init.orthogonal_(lin.weight, np.sqrt(2))
|
|
133
|
+
nn.init.constant_(lin.bias, 0.0)
|
|
134
|
+
mods.append(lin)
|
|
135
|
+
if i < len(dims) - 2 or not plain_last:
|
|
136
|
+
mods.append(act())
|
|
137
|
+
mods.append(nn.LayerNorm(dims[i + 1]))
|
|
138
|
+
return nn.Sequential(*mods)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class ActorStochasticMLP(nn.Module):
|
|
142
|
+
def __init__(self, obs_dim, act_dim, units=(128, 64, 32), activation="elu",
|
|
143
|
+
logstd_init=-1.0, device="cuda", out_bias=None, lattice=False, lattice_alpha=1.0):
|
|
144
|
+
super().__init__()
|
|
145
|
+
self.mu_net = _mlp([obs_dim, *units, act_dim], activation, orthogonal=False).to(device) # DiffRL stochastic actor = PyTorch default init
|
|
146
|
+
# Relaxed-start init (DiffRL small-action-init idea): tiny last-layer weights + a bias so the
|
|
147
|
+
# UNTRAINED policy outputs a near-constant baseline action. For the myoLeg muscle env where
|
|
148
|
+
# u = 0.5*(tanh(a)+1) in [0,1], out_bias=-1.5 -> u ~ 0.05 (muscles RELAXED) instead of the
|
|
149
|
+
# default-init ~0.5 (co-contraction -> stiff legs from the very first step). None = default init.
|
|
150
|
+
if out_bias is not None:
|
|
151
|
+
last = [m for m in self.mu_net if isinstance(m, nn.Linear)][-1]
|
|
152
|
+
nn.init.uniform_(last.weight, -1e-3, 1e-3)
|
|
153
|
+
nn.init.constant_(last.bias, float(out_bias))
|
|
154
|
+
self.obs_dim, self.act_dim = obs_dim, act_dim
|
|
155
|
+
# Lattice exploration (Chiappa et al. 2023, arXiv:2305.20065; default OFF => diagonal Gaussian,
|
|
156
|
+
# byte-identical). ON: correlated action noise induced by the final linear layer W (= the policy's
|
|
157
|
+
# own emergent actuator synergies, NO external data). Non-state-dependent variant (their
|
|
158
|
+
# LatticeNoiseDistribution): Sigma = W diag(S_x^2) W^T + diag(S_a^2). logstd = [S_a (act_dim); S_x
|
|
159
|
+
# (latent_dim)]; S_x is offset by ln(alpha) so alpha scales latent vs action noise (alpha=0-like =>
|
|
160
|
+
# diagonal). mu_net[:-1] = feature net -> latent x; mu_net[-1] = W (the mean layer).
|
|
161
|
+
self.lattice = bool(lattice)
|
|
162
|
+
self._latent_dim = int(units[-1])
|
|
163
|
+
if self.lattice:
|
|
164
|
+
ls = torch.empty(act_dim + self._latent_dim, dtype=torch.float32, device=device)
|
|
165
|
+
ls[:act_dim] = logstd_init
|
|
166
|
+
ls[act_dim:] = logstd_init + float(np.log(max(lattice_alpha, 1e-8)))
|
|
167
|
+
self.logstd = nn.Parameter(ls)
|
|
168
|
+
else:
|
|
169
|
+
self.logstd = nn.Parameter(torch.ones(act_dim, dtype=torch.float32, device=device) * logstd_init)
|
|
170
|
+
|
|
171
|
+
def _lattice_dist(self, obs):
|
|
172
|
+
"""Low-rank Lattice distribution N(mu, diag(S_a^2) + W diag(S_x^2) W^T). W = the final linear
|
|
173
|
+
(the emergent synergy basis); mu = W x + b for latent x = feature net(obs). Returns a
|
|
174
|
+
_LatticeDist that does all Gaussian math via the (H,H) Woodbury capacitance -- NO dense (A,A)
|
|
175
|
+
covariance is ever formed or factorized (the dense variant's full-body OOM / throughput wall)."""
|
|
176
|
+
x = self.mu_net[:-1](obs) # feature net -> latent (batch, H)
|
|
177
|
+
mu = self.mu_net[-1](x) # mean (batch, A)
|
|
178
|
+
std = self.logstd.exp()
|
|
179
|
+
sa = std[: self.act_dim] # (A,) action std
|
|
180
|
+
sx = std[self.act_dim :] # (H,) latent std
|
|
181
|
+
return _LatticeDist(mu, sa, sx, self.mu_net[-1].weight)
|
|
182
|
+
|
|
183
|
+
def forward(self, obs, deterministic=False):
|
|
184
|
+
if self.lattice:
|
|
185
|
+
dist = self._lattice_dist(obs)
|
|
186
|
+
return dist.mean if deterministic else dist.rsample() # rsample = reparameterized
|
|
187
|
+
mu = self.mu_net(obs)
|
|
188
|
+
if deterministic:
|
|
189
|
+
return mu
|
|
190
|
+
return Normal(mu, self.logstd.exp()).rsample() # reparameterized -> grad flows to mu, logstd
|
|
191
|
+
|
|
192
|
+
def distribution(self, obs):
|
|
193
|
+
"""Pre-tanh action distribution. PPO/RPO need log_prob/entropy/KL over the raw action a;
|
|
194
|
+
the env is fed tanh(a) (GpuMyoLegVecEnv maps [-1,1] -> activation), and -- matching DiffRL/
|
|
195
|
+
ShacVec -- no tanh Jacobian correction is applied, so SHAC/PPO/RPO share one action interface.
|
|
196
|
+
SHAC itself keeps using forward(); this is additive. Lattice => low-rank _LatticeDist."""
|
|
197
|
+
if self.lattice:
|
|
198
|
+
return self._lattice_dist(obs)
|
|
199
|
+
return Normal(self.mu_net(obs), self.logstd.exp())
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class TanhTransform(D.Transform):
|
|
203
|
+
"""tanh bijector for the SquashedNormal (SAPO). A faithful port of mineral/nets/distributions.py:
|
|
204
|
+
the numerically stable log-abs-det-Jacobian 2*(log2 - x - softplus(-2x)) = log(1 - tanh(x)^2), and
|
|
205
|
+
cache_size=1 so log_prob(rsample()) reuses the pre-tanh x (never atanh(+-1) -> inf)."""
|
|
206
|
+
|
|
207
|
+
domain = D.constraints.real
|
|
208
|
+
codomain = D.constraints.interval(-1.0, 1.0)
|
|
209
|
+
sign = +1
|
|
210
|
+
|
|
211
|
+
def __init__(self, cache_size=1):
|
|
212
|
+
super().__init__(cache_size=cache_size)
|
|
213
|
+
|
|
214
|
+
@staticmethod
|
|
215
|
+
def atanh(x):
|
|
216
|
+
return 0.5 * (x.log1p() - (-x).log1p())
|
|
217
|
+
|
|
218
|
+
def __eq__(self, other):
|
|
219
|
+
return isinstance(other, TanhTransform)
|
|
220
|
+
|
|
221
|
+
def _call(self, x):
|
|
222
|
+
return x.tanh()
|
|
223
|
+
|
|
224
|
+
def _inverse(self, y):
|
|
225
|
+
return self.atanh(y)
|
|
226
|
+
|
|
227
|
+
def log_abs_det_jacobian(self, x, y):
|
|
228
|
+
return 2.0 * (math.log(2.0) - x - F.softplus(-2.0 * x))
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
class SquashedNormal(D.TransformedDistribution):
|
|
232
|
+
"""Normal(mu, std) pushed through tanh (SAPO action distribution; mineral distributions.py). rsample()
|
|
233
|
+
is reparameterized AND already in (-1,1); log_prob includes the tanh Jacobian correction (via the
|
|
234
|
+
TransformedDistribution machinery); entropy() is the single-sample Monte-Carlo estimate
|
|
235
|
+
-log_prob(rsample()) INCLUDING that Jacobian (matches the reference: draw N=1, per-dim, sum elsewhere)."""
|
|
236
|
+
|
|
237
|
+
def __init__(self, loc, scale, validate_args=False):
|
|
238
|
+
self.loc = loc
|
|
239
|
+
self.scale = scale
|
|
240
|
+
self.base_dist = D.Normal(loc, scale, validate_args=validate_args)
|
|
241
|
+
super().__init__(self.base_dist, [TanhTransform()], validate_args=validate_args)
|
|
242
|
+
|
|
243
|
+
@property
|
|
244
|
+
def mean(self):
|
|
245
|
+
mu = self.loc
|
|
246
|
+
for tr in self.transforms:
|
|
247
|
+
mu = tr(mu)
|
|
248
|
+
return mu
|
|
249
|
+
|
|
250
|
+
def entropy(self, N=1):
|
|
251
|
+
# empirical entropy of the squashed law: E[-log p(a)] via a single reparameterized draw.
|
|
252
|
+
# Returns (batch, act_dim); the caller sums over the action dimension.
|
|
253
|
+
x = self.rsample((N,))
|
|
254
|
+
log_p = self.log_prob(x)
|
|
255
|
+
return -log_p.mean(axis=0)
|
|
256
|
+
|
|
257
|
+
def rsample_eps(self, eps):
|
|
258
|
+
"""rsample() with its standard-normal draw passed in (the eager action noise, CAPTURE_PLAN.md P2): Normal.rsample's
|
|
259
|
+
`loc + eps * scale`, then the transforms, the same operations in the same order, so it is bitwise to rsample() given the
|
|
260
|
+
same eps. eps: (B, A) for an action, (N, B, A) for N draws."""
|
|
261
|
+
x = self.loc + eps * self.scale
|
|
262
|
+
for transform in self.transforms:
|
|
263
|
+
x = transform(x)
|
|
264
|
+
return x
|
|
265
|
+
|
|
266
|
+
def entropy_eps(self, eps):
|
|
267
|
+
"""entropy() with its draw passed in: eps (N, B, A)"""
|
|
268
|
+
x = self.rsample_eps(eps)
|
|
269
|
+
log_p = self.log_prob(x)
|
|
270
|
+
return -log_p.mean(axis=0)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
class PhaseGate(nn.Module):
|
|
274
|
+
"""DeepLoco's phase-gated input (biped3d_llc_actor_net.prototxt / _critic_net.prototxt, 518f502): the observation carries
|
|
275
|
+
K one-hot phase-bin slots (`bin_idx`); every other input is multiplied by each bin and the K products are concatenated,
|
|
276
|
+
bin-major (slice0 -> tile_phase{k} x data_char_task -> Eltwise PROD -> bilin_state Concat), so the first layer has one weight
|
|
277
|
+
block per phase bin. The bins themselves are not passed on. No parameters (its index buffers are not saved), so a
|
|
278
|
+
checkpoint's keys are those of the ungated net with a wider first layer."""
|
|
279
|
+
|
|
280
|
+
def __init__(self, obs_dim, bin_idx, device="cuda"):
|
|
281
|
+
super().__init__()
|
|
282
|
+
bins = [int(i) for i in bin_idx]
|
|
283
|
+
assert len(bins) >= 2 and len(set(bins)) == len(bins) and all(0 <= i < obs_dim for i in bins), (bins, obs_dim)
|
|
284
|
+
rest = [i for i in range(obs_dim) if i not in set(bins)]
|
|
285
|
+
self.register_buffer("bins", torch.tensor(bins, dtype=torch.long, device=device), persistent=False)
|
|
286
|
+
self.register_buffer("rest", torch.tensor(rest, dtype=torch.long, device=device), persistent=False)
|
|
287
|
+
self.in_dim, self.out_dim = obs_dim, len(bins) * len(rest)
|
|
288
|
+
|
|
289
|
+
def forward(self, obs):
|
|
290
|
+
assert obs.shape[-1] == self.in_dim, (obs.shape, self.in_dim)
|
|
291
|
+
b, r = obs[..., self.bins], obs[..., self.rest]
|
|
292
|
+
return (b[..., :, None] * r[..., None, :]).reshape(*obs.shape[:-1], self.out_dim)
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
class ActorSquashedMLP(nn.Module):
|
|
296
|
+
"""State-dependent squashed-Normal actor for SAPO (Soft Analytic Policy Optimization, Xing et al.
|
|
297
|
+
ICLR 2025, arXiv:2412.12089). A shared feature trunk (obs -> units, Linear+act+LayerNorm on EVERY
|
|
298
|
+
layer) then TWO heads: mu = Linear(units[-1], act_dim) and logstd = Linear(units[-1], act_dim).
|
|
299
|
+
distribution(obs) = SquashedNormal(mu, exp(clamp(logstd, -5, 2))), whose rsample() is ALREADY in
|
|
300
|
+
[-1,1] -- SapoVec feeds it to the env directly (identity _env_action; NO second tanh).
|
|
301
|
+
|
|
302
|
+
forward() returns the PRE-tanh action (deterministic -> mu; stochastic -> Normal(mu,std).rsample()),
|
|
303
|
+
matching the ActorStochasticMLP convention so the eval harness's torch.tanh(algo.act(...)) squashes it
|
|
304
|
+
exactly (tanh(mu) = the SquashedNormal mean). Mirrors mineral models.Actor(fixed_sigma=False,
|
|
305
|
+
dist=squashed_normal). out_bias is kept (relaxed-muscle init of the mu head, as in ActorStochasticMLP)."""
|
|
306
|
+
|
|
307
|
+
LOGSTD_MIN, LOGSTD_MAX = -5.0, 2.0
|
|
308
|
+
|
|
309
|
+
def __init__(self, obs_dim, act_dim, units=(128, 64, 32), activation="silu",
|
|
310
|
+
device="cuda", out_bias=None, phase_bins=None):
|
|
311
|
+
super().__init__()
|
|
312
|
+
# phase_bins: the observation's one-hot phase-bin slots for DeepLoco's gated input (PhaseGate); None = ungated
|
|
313
|
+
self.gate = PhaseGate(obs_dim, phase_bins, device) if phase_bins is not None else None
|
|
314
|
+
# shared feature trunk: plain_last=False -> units[-1] output already has act+LayerNorm applied
|
|
315
|
+
# (the representation the mu/logstd heads read). DiffRL/our idiom: Linear -> act -> LayerNorm.
|
|
316
|
+
in_dim = self.gate.out_dim if self.gate is not None else obs_dim
|
|
317
|
+
self.feature_net = _mlp([in_dim, *units], activation, orthogonal=False, plain_last=False).to(device)
|
|
318
|
+
self.mu = nn.Linear(units[-1], act_dim).to(device)
|
|
319
|
+
self.logstd = nn.Linear(units[-1], act_dim).to(device)
|
|
320
|
+
# Relaxed-start init of the MEAN head (same idea as ActorStochasticMLP.out_bias): tiny last-layer
|
|
321
|
+
# weights + a constant bias so the untrained squashed mean ~ tanh(out_bias). For the myoLeg muscle
|
|
322
|
+
# env (u = 0.5*(a+1)), out_bias=-1.5 -> mean action ~ -0.905 -> u ~ 0.047 (muscles RELAXED). None =
|
|
323
|
+
# default init. The logstd head keeps default init (state-dependent exploration is learned).
|
|
324
|
+
if out_bias is not None:
|
|
325
|
+
nn.init.uniform_(self.mu.weight, -1e-3, 1e-3)
|
|
326
|
+
if np.ndim(out_bias) == 0:
|
|
327
|
+
nn.init.constant_(self.mu.bias, float(out_bias))
|
|
328
|
+
else: # per-action (DN_OUT_BIAS_FILE): one value per muscle
|
|
329
|
+
ob = torch.as_tensor(np.asarray(out_bias, dtype=np.float32), device=self.mu.bias.device)
|
|
330
|
+
assert ob.shape == self.mu.bias.shape, (ob.shape, self.mu.bias.shape)
|
|
331
|
+
with torch.no_grad():
|
|
332
|
+
self.mu.bias.copy_(ob)
|
|
333
|
+
self.obs_dim, self.act_dim = obs_dim, act_dim
|
|
334
|
+
|
|
335
|
+
def distribution(self, obs):
|
|
336
|
+
x = self.feature_net(self.gate(obs) if self.gate is not None else obs)
|
|
337
|
+
logstd = torch.clamp(self.logstd(x), self.LOGSTD_MIN, self.LOGSTD_MAX)
|
|
338
|
+
return SquashedNormal(self.mu(x), logstd.exp())
|
|
339
|
+
|
|
340
|
+
def forward(self, obs, deterministic=False):
|
|
341
|
+
# PRE-tanh action (the ActorStochasticMLP convention: callers / the env apply the squash).
|
|
342
|
+
x = self.feature_net(self.gate(obs) if self.gate is not None else obs)
|
|
343
|
+
mu = self.mu(x)
|
|
344
|
+
if deterministic:
|
|
345
|
+
return mu
|
|
346
|
+
logstd = torch.clamp(self.logstd(x), self.LOGSTD_MIN, self.LOGSTD_MAX)
|
|
347
|
+
return Normal(mu, logstd.exp()).rsample()
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
class _ConcatMLP(nn.Module):
|
|
351
|
+
"""ControlVAE's encoder MLP (ControlVAECore/Model/modules.py `Encoder`): the input `x` is concatenated to the
|
|
352
|
+
input of EVERY layer, the first one also takes the condition `c`: h = act(L0([x, c])), h = act(Lk([x, h])),
|
|
353
|
+
out = Lout([x, h]). No normalisation layers, PyTorch default init (as there)."""
|
|
354
|
+
|
|
355
|
+
def __init__(self, x_dim, c_dim, units, out_dim, activation):
|
|
356
|
+
super().__init__()
|
|
357
|
+
assert len(units) >= 1, units
|
|
358
|
+
dims_in = [x_dim + c_dim] + [x_dim + u for u in units[:-1]]
|
|
359
|
+
self.hidden = nn.ModuleList([nn.Linear(i, o) for i, o in zip(dims_in, units)])
|
|
360
|
+
self.out = nn.Linear(x_dim + units[-1], out_dim)
|
|
361
|
+
self.act = _ACT[activation]()
|
|
362
|
+
|
|
363
|
+
def forward(self, x, c=None):
|
|
364
|
+
h = x if c is None else torch.cat([x, c], dim=-1)
|
|
365
|
+
h = self.act(self.hidden[0](h))
|
|
366
|
+
for lin in self.hidden[1:]:
|
|
367
|
+
h = self.act(lin(torch.cat([x, h], dim=-1)))
|
|
368
|
+
return self.out(torch.cat([x, h], dim=-1))
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
class LatentSkillEncoder(nn.Module):
|
|
372
|
+
"""The latent skill model's prior and posterior (ControlVAE, Yao et al. 2022, arXiv:2210.06063 Sec. 3.4.1;
|
|
373
|
+
MuscleVAE, Feng et al. 2023, arXiv:2312.07340 App. B):
|
|
374
|
+
|
|
375
|
+
prior p(z | s) = N(mu_p(s), sigma^2 I)
|
|
376
|
+
posterior q(z | s, s~') = N(mu_p(s) + mu_q(s, s~'), sigma^2 I) s~' = the next reference frame
|
|
377
|
+
|
|
378
|
+
sigma_p = sigma_q = 0.3 and the posterior mean is the prior mean plus a trainable OFFSET, so the KL has the closed
|
|
379
|
+
form KL(q || p) = ||mu_q||^2 / (2 sigma^2) (ControlVAE's SimpleLearnablePriorEncoder.kl_loss, summed over z).
|
|
380
|
+
mu_p and mu_q are _ConcatMLPs (ELU): the prior concatenates s to the input of each layer, the posterior s~'
|
|
381
|
+
(with s also in its first layer), as the paper's "we concatenate the input of each layer of the prior and
|
|
382
|
+
posterior networks with s_t and s_{t+1}". Hidden layers default to the papers' "two 512-unit hidden layers";
|
|
383
|
+
the released ControlVAE code builds three from its `hidden_layer_num: 2` (one first layer + two), which
|
|
384
|
+
`units` reproduces as (512, 512, 512).
|
|
385
|
+
|
|
386
|
+
z is drawn with the reparameterisation trick, so a return differentiated through the simulator reaches both
|
|
387
|
+
mu_p and mu_q through z; the KL reaches mu_q only (it does not depend on mu_p)."""
|
|
388
|
+
|
|
389
|
+
def __init__(self, obs_dim, ref_dim, latent_dim=64, units=(512, 512), sigma=0.3, activation="elu",
|
|
390
|
+
device="cuda"):
|
|
391
|
+
super().__init__()
|
|
392
|
+
assert latent_dim > 0 and sigma > 0.0, (latent_dim, sigma)
|
|
393
|
+
self.obs_dim, self.ref_dim, self.latent_dim, self.sigma = int(obs_dim), int(ref_dim), int(latent_dim), float(sigma)
|
|
394
|
+
self.prior = _ConcatMLP(obs_dim, 0, units, latent_dim, activation).to(device)
|
|
395
|
+
self.posterior = _ConcatMLP(ref_dim, obs_dim, units, latent_dim, activation).to(device)
|
|
396
|
+
|
|
397
|
+
def prior_mean(self, obs):
|
|
398
|
+
return self.prior(obs)
|
|
399
|
+
|
|
400
|
+
def posterior_mean(self, obs, ref):
|
|
401
|
+
return self.prior(obs) + self.posterior(ref, obs)
|
|
402
|
+
|
|
403
|
+
def kl(self, mu_q):
|
|
404
|
+
"""KL(q || p) per env, (N,): ||mu_q||^2 / (2 sigma^2), the closed form for two Gaussians of equal sigma."""
|
|
405
|
+
return (mu_q * mu_q).sum(-1) / (2.0 * self.sigma * self.sigma)
|
|
406
|
+
|
|
407
|
+
def sample_posterior(self, obs, ref):
|
|
408
|
+
"""z ~ q(z | s, s~') by reparameterisation, and the per-env KL(q || p). Returns (z (N,Z), kl (N,))."""
|
|
409
|
+
mu_p = self.prior(obs)
|
|
410
|
+
mu_q = self.posterior(ref, obs)
|
|
411
|
+
z = mu_p + mu_q + self.sigma * torch.randn_like(mu_p)
|
|
412
|
+
return z, self.kl(mu_q)
|
|
413
|
+
|
|
414
|
+
def sample_prior(self, obs):
|
|
415
|
+
"""z ~ p(z | s), the generation mode (no reference)."""
|
|
416
|
+
mu_p = self.prior(obs)
|
|
417
|
+
return mu_p + self.sigma * torch.randn_like(mu_p)
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
class ActorSquashedLatentMLP(nn.Module):
|
|
421
|
+
"""The latent skill model's DECODER pi(a | s, z) as a SAPO actor: ActorSquashedMLP with z concatenated to the input
|
|
422
|
+
of every layer, the mean and logstd heads included. It never sees the reference, only s and z, which is what makes z
|
|
423
|
+
the skill code.
|
|
424
|
+
|
|
425
|
+
DEVIATION from the papers, stated: ControlVAE / MuscleVAE decode with a mixture of experts (6 experts x 3 x 512 ELU,
|
|
426
|
+
a 2 x 64 gating network, z concatenated to the input of each expert layer and that input layer-normalised, a fixed
|
|
427
|
+
sigma_pi = 0.05). Phase 1 keeps this project's SAPO actor (Linear -> act -> LayerNorm on each layer, the state-
|
|
428
|
+
dependent squashed Normal, SAPO's entropy and temperature) and takes over only the papers' "z at every layer"."""
|
|
429
|
+
|
|
430
|
+
LOGSTD_MIN, LOGSTD_MAX = ActorSquashedMLP.LOGSTD_MIN, ActorSquashedMLP.LOGSTD_MAX
|
|
431
|
+
|
|
432
|
+
def __init__(self, obs_dim, latent_dim, act_dim, units=(128, 64, 32), activation="silu", device="cuda",
|
|
433
|
+
out_bias=None):
|
|
434
|
+
super().__init__()
|
|
435
|
+
act = _ACT[activation]
|
|
436
|
+
dims_in = [obs_dim] + list(units[:-1])
|
|
437
|
+
self.layers = nn.ModuleList([nn.Linear(i + latent_dim, o) for i, o in zip(dims_in, units)]).to(device)
|
|
438
|
+
self.acts = nn.ModuleList([act() for _ in units]).to(device)
|
|
439
|
+
self.norms = nn.ModuleList([nn.LayerNorm(o) for o in units]).to(device)
|
|
440
|
+
self.mu = nn.Linear(units[-1] + latent_dim, act_dim).to(device)
|
|
441
|
+
self.logstd = nn.Linear(units[-1] + latent_dim, act_dim).to(device)
|
|
442
|
+
if out_bias is not None: # the relaxed-start mean head, as ActorSquashedMLP
|
|
443
|
+
nn.init.uniform_(self.mu.weight, -1e-3, 1e-3)
|
|
444
|
+
if np.ndim(out_bias) == 0:
|
|
445
|
+
nn.init.constant_(self.mu.bias, float(out_bias))
|
|
446
|
+
else:
|
|
447
|
+
ob = torch.as_tensor(np.asarray(out_bias, dtype=np.float32), device=self.mu.bias.device)
|
|
448
|
+
assert ob.shape == self.mu.bias.shape, (ob.shape, self.mu.bias.shape)
|
|
449
|
+
with torch.no_grad():
|
|
450
|
+
self.mu.bias.copy_(ob)
|
|
451
|
+
self.obs_dim, self.latent_dim, self.act_dim = obs_dim, latent_dim, act_dim
|
|
452
|
+
|
|
453
|
+
def features(self, obs, z):
|
|
454
|
+
h = obs
|
|
455
|
+
for lin, a, ln in zip(self.layers, self.acts, self.norms):
|
|
456
|
+
h = ln(a(lin(torch.cat([h, z], dim=-1))))
|
|
457
|
+
return torch.cat([h, z], dim=-1)
|
|
458
|
+
|
|
459
|
+
def distribution(self, obs, z):
|
|
460
|
+
x = self.features(obs, z)
|
|
461
|
+
logstd = torch.clamp(self.logstd(x), self.LOGSTD_MIN, self.LOGSTD_MAX)
|
|
462
|
+
return SquashedNormal(self.mu(x), logstd.exp())
|
|
463
|
+
|
|
464
|
+
def forward(self, obs, z, deterministic=False):
|
|
465
|
+
# PRE-tanh action, the ActorSquashedMLP convention
|
|
466
|
+
x = self.features(obs, z)
|
|
467
|
+
mu = self.mu(x)
|
|
468
|
+
if deterministic:
|
|
469
|
+
return mu
|
|
470
|
+
logstd = torch.clamp(self.logstd(x), self.LOGSTD_MIN, self.LOGSTD_MAX)
|
|
471
|
+
return Normal(mu, logstd.exp()).rsample()
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
class LatentTaskPolicy(nn.Module):
|
|
475
|
+
"""The latent skill model's TASK policy offset mu_g(s, g) (MuscleVAE App. B.3 eq. 43, ControlVAE Sec. 4.2 eq. 21): the
|
|
476
|
+
high-level policy is N(mu_p(s) + mu_g(s, g), sigma_g^2 I) over z, an OFFSET on the frozen state prior's mean. An MLP
|
|
477
|
+
on [s, g] with three 256-unit ELU hidden layers (MuscleVAE's text; ControlVAE's released build_mlp(obs + 3, latent,
|
|
478
|
+
3, 256, 'ELU'): Linear and ELU only, no normalisation layers, PyTorch default init).
|
|
479
|
+
|
|
480
|
+
DEVIATION, stated: the output layer starts at ~0 (weights uniform +-1e-3, bias 0), so the untrained task policy is
|
|
481
|
+
the prior itself (the P2 generation mode) instead of a random offset on it."""
|
|
482
|
+
|
|
483
|
+
def __init__(self, obs_dim, task_dim, latent_dim, units=(256, 256, 256), activation="elu", device="cuda"):
|
|
484
|
+
super().__init__()
|
|
485
|
+
assert len(units) >= 1, units
|
|
486
|
+
act = _ACT[activation]
|
|
487
|
+
dims = [obs_dim + task_dim, *units]
|
|
488
|
+
mods = []
|
|
489
|
+
for i, o in zip(dims[:-1], dims[1:]):
|
|
490
|
+
mods += [nn.Linear(i, o), act()]
|
|
491
|
+
self.hidden = nn.Sequential(*mods).to(device)
|
|
492
|
+
self.out = nn.Linear(units[-1], latent_dim).to(device)
|
|
493
|
+
nn.init.uniform_(self.out.weight, -1e-3, 1e-3)
|
|
494
|
+
nn.init.zeros_(self.out.bias)
|
|
495
|
+
self.obs_dim, self.task_dim, self.latent_dim = int(obs_dim), int(task_dim), int(latent_dim)
|
|
496
|
+
|
|
497
|
+
def forward(self, obs, task):
|
|
498
|
+
return self.out(self.hidden(torch.cat([obs, task], dim=-1)))
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
class CriticMLP(nn.Module):
|
|
502
|
+
def __init__(self, obs_dim, units=(64, 64), activation="elu", device="cuda"):
|
|
503
|
+
super().__init__()
|
|
504
|
+
self.critic = _mlp([obs_dim, *units, 1], activation, orthogonal=True).to(device)
|
|
505
|
+
|
|
506
|
+
def forward(self, obs):
|
|
507
|
+
return self.critic(obs)
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
class EnsembleCritic(nn.Module):
|
|
511
|
+
"""n independent value heads (SAPO uses n=2). forward(obs, return_type): 'min' -> elementwise min
|
|
512
|
+
over the ensemble, 'avg' -> mean, 'min_and_avg' -> (min, avg), 'all' -> per-critic values stacked
|
|
513
|
+
(n_critics, batch, 1). Each head is a CriticMLP (orthogonal init). SAPO bootstraps the ACTOR return
|
|
514
|
+
with 'avg' and the CRITIC target with 'min' (clipped-double-Q, no target network). Mirrors mineral
|
|
515
|
+
models.EnsembleCritic (non-vmap path)."""
|
|
516
|
+
|
|
517
|
+
def __init__(self, obs_dim, units=(64, 64), activation="silu", device="cuda", n_critics=2, phase_bins=None):
|
|
518
|
+
super().__init__()
|
|
519
|
+
self.n_critics = int(n_critics)
|
|
520
|
+
# DeepLoco gates its critic's input by the phase bins too (biped3d_llc_critic_net.prototxt); None = ungated
|
|
521
|
+
self.gate = PhaseGate(obs_dim, phase_bins, device) if phase_bins is not None else None
|
|
522
|
+
in_dim = self.gate.out_dim if self.gate is not None else obs_dim
|
|
523
|
+
self.critics = nn.ModuleList(
|
|
524
|
+
[_mlp([in_dim, *units, 1], activation, orthogonal=True).to(device) for _ in range(self.n_critics)])
|
|
525
|
+
|
|
526
|
+
def forward(self, obs, return_type="min"):
|
|
527
|
+
if self.gate is not None:
|
|
528
|
+
obs = self.gate(obs)
|
|
529
|
+
vs = torch.stack([c(obs) for c in self.critics]) # (n_critics, batch, 1)
|
|
530
|
+
if return_type == "all":
|
|
531
|
+
return vs
|
|
532
|
+
if return_type == "min":
|
|
533
|
+
return torch.min(vs, dim=0).values
|
|
534
|
+
if return_type == "avg":
|
|
535
|
+
return torch.mean(vs, dim=0)
|
|
536
|
+
if return_type == "min_and_avg":
|
|
537
|
+
return torch.min(vs, dim=0).values, torch.mean(vs, dim=0)
|
|
538
|
+
raise ValueError(return_type)
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
class RunningMeanStd:
|
|
542
|
+
"""Parallel-variance running normalizer (DiffRL utils/running_mean_std.py). Not an nn.Module
|
|
543
|
+
-- holds running mean/var buffers updated under no_grad during the rollout."""
|
|
544
|
+
|
|
545
|
+
def __init__(self, shape, device="cuda", epsilon=1e-4):
|
|
546
|
+
self.mean = torch.zeros(shape, dtype=torch.float32, device=device)
|
|
547
|
+
self.var = torch.ones(shape, dtype=torch.float32, device=device)
|
|
548
|
+
# the count lives on the device (CAPTURE_PLAN.md P2 (ii)): a Python float would be baked into a captured update. f64,
|
|
549
|
+
# as the Python float it replaces; `count` reads and sets it as a float (checkpoints, loads), never per step
|
|
550
|
+
self._count = torch.tensor(float(epsilon), dtype=torch.float64, device=device)
|
|
551
|
+
# (shape,) bool: slots passed through unnormalized (DeepLoco's eOffsetScaleTypeFixed, its phase bins); None = every slot
|
|
552
|
+
# normalized. Set from the env by the algorithm, never saved: the env that rebuilds the algorithm sets it again.
|
|
553
|
+
self.fixed = None
|
|
554
|
+
|
|
555
|
+
@property
|
|
556
|
+
def count(self):
|
|
557
|
+
return float(self._count) # a host read: checkpoints and logs only
|
|
558
|
+
|
|
559
|
+
@count.setter
|
|
560
|
+
def count(self, v):
|
|
561
|
+
self._count = torch.as_tensor(v, dtype=torch.float64, device=self.mean.device).clone()
|
|
562
|
+
|
|
563
|
+
@torch.no_grad()
|
|
564
|
+
def update(self, arr): # arr [batch, *shape]
|
|
565
|
+
# in place, with the count on the device. Bitwise to the Python-float form it replaces: there, every `tensor op
|
|
566
|
+
# scalar` cast the double scalar to f32 inside the kernel, and a division by a CPU scalar ran as a multiplication by
|
|
567
|
+
# its f32 reciprocal (verified on the 4090: this form bitwise over 300 updates at counts 1e-4, 3.3e7, 1.7e9; a true
|
|
568
|
+
# division by the f32 tensor is not)
|
|
569
|
+
bmean = arr.mean(dim=0)
|
|
570
|
+
bvar = arr.var(dim=0, unbiased=False)
|
|
571
|
+
bcount = arr.shape[0]
|
|
572
|
+
delta = bmean - self.mean
|
|
573
|
+
if self.mean.device.type != "cuda": # off the GPU, the original Python-float arithmetic exactly (verified on CUDA only)
|
|
574
|
+
count = float(self._count)
|
|
575
|
+
tot = count + bcount
|
|
576
|
+
self.mean.copy_(self.mean + delta * bcount / tot)
|
|
577
|
+
m2 = self.var * count + bvar * bcount + delta ** 2 * count * bcount / tot
|
|
578
|
+
self.var.copy_(m2 / tot)
|
|
579
|
+
self._count.fill_(tot)
|
|
580
|
+
return
|
|
581
|
+
tot = self._count + bcount # bcount stays a Python int (static per shape; no host-to-device copy)
|
|
582
|
+
c32 = self._count.float()
|
|
583
|
+
inv = 1.0 / tot.float()
|
|
584
|
+
self.mean.copy_(self.mean + delta * bcount * inv)
|
|
585
|
+
m_a = self.var * c32
|
|
586
|
+
m_b = bvar * bcount
|
|
587
|
+
m2 = m_a + m_b + delta ** 2 * c32 * bcount * inv
|
|
588
|
+
self.var.copy_(m2 * inv)
|
|
589
|
+
self._count.copy_(tot)
|
|
590
|
+
|
|
591
|
+
def normalize(self, arr):
|
|
592
|
+
out = (arr - self.mean) / torch.sqrt(self.var + 1e-5)
|
|
593
|
+
if self.fixed is not None:
|
|
594
|
+
out = torch.where(self.fixed, arr, out)
|
|
595
|
+
return out
|
|
596
|
+
|
|
597
|
+
def state_dict(self):
|
|
598
|
+
# copies: update() now writes in place, so a state_dict held for later must not follow the live buffers
|
|
599
|
+
return {"mean": self.mean.clone(), "var": self.var.clone(), "count": self.count}
|