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
diffneusim/rl/g1_ppo.py
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
"""Arm A (line 23, docs/training/campaigns/g1/seconds.md): InstantMimic's seconds-level PPO recipe on the G1 env of g1_soft_env.
|
|
2
|
+
|
|
3
|
+
Every setting is InstantMimic's humanoid imitation base (config/humanoid/imitation/base.yaml at 947430ee, the HPO-derived base its
|
|
4
|
+
five motions share), with its code as the reference for the update rules:
|
|
5
|
+
model one shared MLP trunk obs -> 384 -> 384 -> 192 (SiLU) with a mean head (29) and a value head (1); a state-independent
|
|
6
|
+
log-std parameter, initial -2, clamped to [-20, 2]; actions unsquashed (action_transform none)
|
|
7
|
+
data 2,048 worlds x 6 control steps per iteration; running standardisers on observations and on values (RunningStandardScaler)
|
|
8
|
+
returns GAE, gamma 0.95, lambda 0.95; time-limit bootstrap (a time-out adds gamma V(s') to its reward)
|
|
9
|
+
update 5 epochs x 4 minibatches, shuffled per update; clipped surrogate (ratio clip 0.2); value loss scale 4.5 with the
|
|
10
|
+
predicted value clamped to old +- 0.2 (value_loss_clip_mode clamp); entropy 1e-3; grad-norm clip 1.0
|
|
11
|
+
lr 1e-3, KL-adaptive per epoch (rl/ppo/agent.py _update_lr_tensor_kernel): kl > 2 x 0.1 -> lr / 1.5, kl < 0.5 x 0.1 -> lr x 1.5,
|
|
12
|
+
within [1e-6, 1e-2]; the sampled KL estimator ((ratio - 1) - log ratio)
|
|
13
|
+
optimiser Muon (InstantMimic's CapturableMuon, single-tensor path; Nesterov, momentum 0.95, 5 Newton-Schulz steps in bf16,
|
|
14
|
+
match_rms_adamw, weight decay 3e-5, eps 2e-5; one device lr shared with AdamW)
|
|
15
|
+
on the trunk's hidden matrices (not the first layer, not the heads: rl/optimizers.py _is_muon_hidden_layer_param);
|
|
16
|
+
AdamW (0.9, 0.999), eps 2e-5, weight decay 3e-5 on the rest
|
|
17
|
+
episodes random start frame and joint noise N(0, 0.02) at every reset (reset.random_start, motion_noise_std); early
|
|
18
|
+
termination as the env's (BeyondMimic's G1 terms + reward < 0.15 for 4 steps); adaptive sampling off (its base)
|
|
19
|
+
Scoring: g1_soft_eval (shared by every arm). Labelled deviations: the observation is g1_soft_env.obs_phc (PHC-style), the observer standardiser updates once per iteration on the
|
|
20
|
+
rollout batch, and the clock is ours (CLOCK_MONOTONIC_RAW around the training iterations; the benchmark and the first, compiling
|
|
21
|
+
iteration's time excluded, its learning kept).
|
|
22
|
+
"""
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
import math
|
|
26
|
+
import time
|
|
27
|
+
|
|
28
|
+
import torch
|
|
29
|
+
import torch.nn as nn
|
|
30
|
+
|
|
31
|
+
from . import g1_soft_env as G
|
|
32
|
+
|
|
33
|
+
CFG = dict(n_env=2048, rollouts=6, gamma=0.95, lam=0.95, epochs=5, minibatches=4, ratio_clip=0.2, value_clip=0.2, value_scale=4.5,
|
|
34
|
+
entropy=1e-3, grad_clip=1.0, lr=1e-3, lr_bounds=(1e-6, 1e-2), kl_threshold=0.1, kl_factor=1.5, layers=(384, 384, 192),
|
|
35
|
+
log_std_init=-2.0, log_std_bounds=(-20.0, 2.0), muon=dict(momentum=0.95, nesterov=True, ns_steps=5, eps=2e-5,
|
|
36
|
+
weight_decay=3e-5, adjust_lr_fn="match_rms_adamw"), adamw=dict(betas=(0.9, 0.999), eps=2e-5, weight_decay=3e-5),
|
|
37
|
+
reset_noise=0.02)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class RunningStd(nn.Module):
|
|
41
|
+
"""skrl's RunningStandardScaler: running mean / variance (parallel update), clip 5, eps 1e-8."""
|
|
42
|
+
|
|
43
|
+
def __init__(self, dim, device, clip=5.0, eps=1e-8):
|
|
44
|
+
super().__init__()
|
|
45
|
+
self.register_buffer("mean", torch.zeros(dim, device=device))
|
|
46
|
+
self.register_buffer("var", torch.ones(dim, device=device))
|
|
47
|
+
self.register_buffer("count", torch.ones((), device=device))
|
|
48
|
+
self.clip, self.eps = clip, eps
|
|
49
|
+
|
|
50
|
+
@torch.no_grad()
|
|
51
|
+
def update(self, x):
|
|
52
|
+
x = x.reshape(-1, self.mean.shape[0])
|
|
53
|
+
bm, bv, bc = x.mean(0), x.var(0, unbiased=False), x.shape[0]
|
|
54
|
+
d = bm - self.mean
|
|
55
|
+
tot = self.count + bc
|
|
56
|
+
self.mean += d * bc / tot
|
|
57
|
+
self.var.copy_((self.var * self.count + bv * bc + d.square() * self.count * bc / tot) / tot)
|
|
58
|
+
self.count.copy_(tot)
|
|
59
|
+
|
|
60
|
+
def forward(self, x, inverse=False):
|
|
61
|
+
if inverse:
|
|
62
|
+
return x * torch.sqrt(self.var + self.eps) + self.mean
|
|
63
|
+
return ((x - self.mean) / torch.sqrt(self.var + self.eps)).clamp(-self.clip, self.clip)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class SharedActorCritic(nn.Module):
|
|
67
|
+
def __init__(self, obs_dim, act_dim, cfg, device):
|
|
68
|
+
super().__init__()
|
|
69
|
+
dims = (obs_dim,) + tuple(cfg["layers"])
|
|
70
|
+
self.trunk = nn.Sequential(*[m for i in range(len(dims) - 1) for m in (nn.Linear(dims[i], dims[i + 1]), nn.SiLU())])
|
|
71
|
+
self.mean_head = nn.Linear(dims[-1], act_dim)
|
|
72
|
+
self.value_head = nn.Linear(dims[-1], 1)
|
|
73
|
+
self.log_std = nn.Parameter(torch.full((act_dim,), float(cfg["log_std_init"])))
|
|
74
|
+
self.lo, self.hi = cfg["log_std_bounds"]
|
|
75
|
+
self.to(device)
|
|
76
|
+
|
|
77
|
+
def forward(self, obs):
|
|
78
|
+
h = self.trunk(obs)
|
|
79
|
+
return self.mean_head(h), self.log_std.clamp(self.lo, self.hi).expand(obs.shape[0], -1), self.value_head(h).squeeze(-1)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
NS_COEFFICIENTS = (3.4445, -4.7750, 2.0315)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def newton_schulz_bf16(grad, steps, eps, coeff=NS_COEFFICIENTS):
|
|
86
|
+
"""InstantMimic's _muon_zero_power_via_newton_schulz (= torch.optim.Muon's), in bfloat16, eager (theirs is torch.compile'd on
|
|
87
|
+
CUDA: the same math, possibly other rounding)."""
|
|
88
|
+
a, b, c = coeff
|
|
89
|
+
x = grad.bfloat16()
|
|
90
|
+
if grad.shape[0] > grad.shape[1]:
|
|
91
|
+
x = x.T
|
|
92
|
+
x = x / x.norm().clamp(min=eps)
|
|
93
|
+
for _ in range(steps):
|
|
94
|
+
gram = x @ x.T
|
|
95
|
+
gram_update = torch.addmm(gram, gram, gram, beta=b, alpha=c)
|
|
96
|
+
x = torch.addmm(x, gram_update, x, beta=a)
|
|
97
|
+
if grad.shape[0] > grad.shape[1]:
|
|
98
|
+
x = x.T
|
|
99
|
+
return x
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class CapturableMuon(torch.optim.Optimizer):
|
|
103
|
+
"""InstantMimic's CapturableMuon (rl/optimizers.py at 947430ee), its single-tensor path: a 0-dim device learning rate (no host
|
|
104
|
+
read, so the update can be captured), decoupled decay 1 - lr wd, Nesterov momentum by lerp, Newton-Schulz, the
|
|
105
|
+
match_rms_adamw scale 0.2 sqrt(max(rows, cols))."""
|
|
106
|
+
|
|
107
|
+
def __init__(self, params, lr, weight_decay, momentum, nesterov, ns_steps, eps, adjust_lr_fn):
|
|
108
|
+
assert adjust_lr_fn == "match_rms_adamw" and torch.is_tensor(lr) and lr.dim() == 0
|
|
109
|
+
super().__init__(params, dict(lr=lr, weight_decay=float(weight_decay), momentum=float(momentum), nesterov=bool(nesterov),
|
|
110
|
+
ns_steps=int(ns_steps), eps=float(eps)))
|
|
111
|
+
for g in self.param_groups:
|
|
112
|
+
assert all(p.ndim == 2 for p in g["params"])
|
|
113
|
+
|
|
114
|
+
@torch.no_grad()
|
|
115
|
+
def step(self):
|
|
116
|
+
for g in self.param_groups:
|
|
117
|
+
lr, mom = g["lr"], g["momentum"]
|
|
118
|
+
decay = 1.0 - lr * g["weight_decay"]
|
|
119
|
+
for p in g["params"]:
|
|
120
|
+
if p.grad is None:
|
|
121
|
+
continue
|
|
122
|
+
st = self.state[p]
|
|
123
|
+
if "momentum_buffer" not in st:
|
|
124
|
+
st["momentum_buffer"] = torch.zeros_like(p.grad, memory_format=torch.preserve_format)
|
|
125
|
+
buf = st["momentum_buffer"]
|
|
126
|
+
buf.lerp_(p.grad, 1.0 - mom)
|
|
127
|
+
upd = p.grad.lerp(buf, mom) if g["nesterov"] else buf
|
|
128
|
+
upd = newton_schulz_bf16(upd, g["ns_steps"], g["eps"])
|
|
129
|
+
adj = lr * (0.2 * math.sqrt(max(p.shape[0], p.shape[1])))
|
|
130
|
+
p.mul_(decay)
|
|
131
|
+
p.add_(upd * (-adj))
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def make_optimisers(model, cfg, lr_t):
|
|
135
|
+
"""Muon on the trunk's hidden matrices (Linear index > 0), AdamW on everything else, both reading the one 0-dim lr tensor
|
|
136
|
+
lr_t (AdamW capturable on CUDA, as InstantMimic's update_cuda_graph path)."""
|
|
137
|
+
lins = [m for m in model.trunk if isinstance(m, nn.Linear)]
|
|
138
|
+
muon = [l.weight for l in lins[1:]]
|
|
139
|
+
ids = {id(p) for p in muon}
|
|
140
|
+
rest = [p for p in model.parameters() if id(p) not in ids]
|
|
141
|
+
mu = CapturableMuon(muon, lr=lr_t, **cfg["muon"])
|
|
142
|
+
cuda = lr_t.device.type == "cuda"
|
|
143
|
+
ad = torch.optim.AdamW(rest, lr=lr_t if cuda else float(lr_t), capturable=cuda, **cfg["adamw"])
|
|
144
|
+
return [mu, ad]
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def gaussian_logp(a, mean, log_std):
|
|
148
|
+
return (-0.5 * ((a - mean) / log_std.exp()).square() - log_std - 0.5 * math.log(2 * math.pi)).sum(-1)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class PPO:
|
|
152
|
+
def __init__(self, env, cfg=CFG, seed=0):
|
|
153
|
+
torch.manual_seed(seed)
|
|
154
|
+
self.env, self.cfg = env, dict(cfg)
|
|
155
|
+
self.dev, n, R = env.dev, env.n, cfg["rollouts"]
|
|
156
|
+
# every draw from the default generator of the device (seeded above): a CUDA graph replays its philox stream, so the
|
|
157
|
+
# eager and the captured iteration draw the same numbers (W2b)
|
|
158
|
+
self.gen = None
|
|
159
|
+
env.reset(torch.ones(n, dtype=torch.bool, device=self.dev), self._starts(n))
|
|
160
|
+
obs = env.observe().float()
|
|
161
|
+
self.obs_dim = obs.shape[1]
|
|
162
|
+
self.model = SharedActorCritic(self.obs_dim, G.NU, cfg, self.dev)
|
|
163
|
+
self.lr_t = torch.tensor(float(cfg["lr"]), device=self.dev) # the device lr: the KL rule updates it without a host read
|
|
164
|
+
self.opts = make_optimisers(self.model, cfg, self.lr_t)
|
|
165
|
+
self.obs_rms = RunningStd(self.obs_dim, self.dev)
|
|
166
|
+
self.val_rms = RunningStd(1, self.dev)
|
|
167
|
+
z = lambda *s: torch.zeros(*s, device=self.dev) # noqa: E731
|
|
168
|
+
self.buf = dict(obs=z(R, n, self.obs_dim), act=z(R, n, G.NU), logp=z(R, n), val=z(R, n), rew=z(R, n), term=z(R, n),
|
|
169
|
+
tout=z(R, n))
|
|
170
|
+
self.obs = obs
|
|
171
|
+
self.it = 0
|
|
172
|
+
self.stats = {}
|
|
173
|
+
|
|
174
|
+
def _starts(self, k):
|
|
175
|
+
return torch.randint(0, self.env.m.T - 1, (k,), generator=self.gen, device=self.dev)
|
|
176
|
+
|
|
177
|
+
@torch.no_grad()
|
|
178
|
+
def rollout(self):
|
|
179
|
+
env, b, n = self.env, self.buf, self.env.n
|
|
180
|
+
self.obs_rms.update(self.obs)
|
|
181
|
+
for k in range(self.cfg["rollouts"]):
|
|
182
|
+
o = self.obs_rms(self.obs)
|
|
183
|
+
mean, log_std, v = self.model(o)
|
|
184
|
+
a = mean + log_std.exp() * torch.randn(mean.shape, generator=self.gen, device=self.dev)
|
|
185
|
+
b["obs"][k], b["act"][k], b["logp"][k] = o, a, gaussian_logp(a, mean, log_std)
|
|
186
|
+
b["val"][k] = self.val_rms(v.unsqueeze(-1), inverse=True).squeeze(-1)
|
|
187
|
+
fr, r, term, tout, info = env.step(a.to(env.dt))
|
|
188
|
+
b["rew"][k], b["term"][k], b["tout"][k] = r.float(), term.float(), (tout & ~term).float()
|
|
189
|
+
done = term | tout
|
|
190
|
+
if self.cfg["reset_noise"] > 0:
|
|
191
|
+
noise = self.cfg["reset_noise"] * torch.randn(n, G.NU, generator=self.gen, device=self.dev).to(env.dt)
|
|
192
|
+
else:
|
|
193
|
+
noise = None
|
|
194
|
+
nxt_obs = env.observe().float()
|
|
195
|
+
# the time-out bootstrap needs V at the state the episode reached, before the reset replaces it
|
|
196
|
+
_, _, v_next = self.model(self.obs_rms(nxt_obs))
|
|
197
|
+
b["rew"][k] += self.cfg["gamma"] * self.val_rms(v_next.unsqueeze(-1), inverse=True).squeeze(-1) * b["tout"][k]
|
|
198
|
+
env.reset(done, self._starts(n), q_noise=noise)
|
|
199
|
+
self.obs = torch.where(done.view(-1, 1), env.observe().float(), nxt_obs)
|
|
200
|
+
_, _, v_last = self.model(self.obs_rms(self.obs))
|
|
201
|
+
return self.val_rms(v_last.unsqueeze(-1), inverse=True).squeeze(-1)
|
|
202
|
+
|
|
203
|
+
@torch.no_grad()
|
|
204
|
+
def gae(self, v_last):
|
|
205
|
+
b, g, lam = self.buf, self.cfg["gamma"], self.cfg["lam"]
|
|
206
|
+
adv = torch.zeros_like(b["rew"])
|
|
207
|
+
last = torch.zeros_like(v_last)
|
|
208
|
+
for k in reversed(range(self.cfg["rollouts"])):
|
|
209
|
+
nv = v_last if k == self.cfg["rollouts"] - 1 else b["val"][k + 1]
|
|
210
|
+
nd = 1.0 - torch.maximum(b["term"][k], b["tout"][k]) # no bootstrap across an episode end (a time-out is in rew)
|
|
211
|
+
delta = b["rew"][k] + g * nv * nd - b["val"][k]
|
|
212
|
+
last = delta + g * lam * nd * last
|
|
213
|
+
adv[k] = last
|
|
214
|
+
ret = adv + b["val"]
|
|
215
|
+
return adv, ret
|
|
216
|
+
|
|
217
|
+
def update(self, adv, ret):
|
|
218
|
+
cfg, b = self.cfg, self.buf
|
|
219
|
+
self.val_rms.update(ret.reshape(-1, 1))
|
|
220
|
+
N = adv.numel()
|
|
221
|
+
flat = {k: v.reshape(N, *v.shape[2:]) for k, v in b.items()}
|
|
222
|
+
adv_f, ret_n = adv.reshape(N), self.val_rms(ret.reshape(N, 1)).squeeze(-1)
|
|
223
|
+
old_v_n = self.val_rms(flat["val"].reshape(N, 1)).squeeze(-1)
|
|
224
|
+
mb = N // cfg["minibatches"]
|
|
225
|
+
kls = []
|
|
226
|
+
for ep in range(cfg["epochs"]):
|
|
227
|
+
perm = torch.argsort(torch.rand(N, generator=self.gen, device=self.dev)) # capturable, unlike a host-sized randperm
|
|
228
|
+
ep_kl = []
|
|
229
|
+
for j in range(cfg["minibatches"]):
|
|
230
|
+
i = perm[j * mb:(j + 1) * mb]
|
|
231
|
+
mean, log_std, v = self.model(flat["obs"][i])
|
|
232
|
+
logp = gaussian_logp(flat["act"][i], mean, log_std)
|
|
233
|
+
log_ratio = logp - flat["logp"][i]
|
|
234
|
+
ratio = log_ratio.exp()
|
|
235
|
+
with torch.no_grad():
|
|
236
|
+
ep_kl.append(((ratio - 1) - log_ratio).mean())
|
|
237
|
+
a = adv_f[i]
|
|
238
|
+
pol = -torch.min(a * ratio, a * ratio.clamp(1 - cfg["ratio_clip"], 1 + cfg["ratio_clip"])).mean()
|
|
239
|
+
v_c = old_v_n[i] + (v - old_v_n[i]).clamp(-cfg["value_clip"], cfg["value_clip"])
|
|
240
|
+
val = (ret_n[i] - v_c).square().mean()
|
|
241
|
+
ent = (log_std + 0.5 * math.log(2 * math.pi * math.e)).sum(-1).mean()
|
|
242
|
+
loss = pol + cfg["value_scale"] * val - cfg["entropy"] * ent
|
|
243
|
+
for o in self.opts:
|
|
244
|
+
o.zero_grad(set_to_none=True)
|
|
245
|
+
loss.backward()
|
|
246
|
+
nn.utils.clip_grad_norm_(self.model.parameters(), cfg["grad_clip"])
|
|
247
|
+
for o in self.opts:
|
|
248
|
+
o.step()
|
|
249
|
+
kl = torch.stack(ep_kl).mean()
|
|
250
|
+
kls.append(kl)
|
|
251
|
+
lo, hi = cfg["lr_bounds"]
|
|
252
|
+
th, fac = cfg["kl_threshold"], cfg["kl_factor"]
|
|
253
|
+
new = torch.where(kl > 2.0 * th, (self.lr_t / fac).clamp_min(lo),
|
|
254
|
+
torch.where(kl < 0.5 * th, (self.lr_t * fac).clamp_max(hi), self.lr_t))
|
|
255
|
+
self.lr_t.copy_(new)
|
|
256
|
+
if self.lr_t.device.type != "cuda": # the CPU AdamW holds a float lr (tests only)
|
|
257
|
+
for gr in self.opts[1].param_groups:
|
|
258
|
+
gr["lr"] = float(self.lr_t)
|
|
259
|
+
# the iteration's stats as one device vector (a captured update cannot read them on the host)
|
|
260
|
+
self.stat_t = torch.stack([torch.stack(kls).mean(), self.lr_t, pol.detach(), val.detach(), self.model.log_std.detach().mean(),
|
|
261
|
+
self.buf["rew"].mean(), self.buf["term"].mean()])
|
|
262
|
+
|
|
263
|
+
STAT_NAMES = ("kl", "lr", "policy_loss", "value_loss", "log_std", "reward", "term_rate")
|
|
264
|
+
|
|
265
|
+
def _sync(self):
|
|
266
|
+
if str(self.dev).startswith("cuda"):
|
|
267
|
+
torch.cuda.synchronize()
|
|
268
|
+
|
|
269
|
+
def _read_stats(self):
|
|
270
|
+
return dict(zip(self.STAT_NAMES, self.stat_t.tolist()))
|
|
271
|
+
|
|
272
|
+
def iteration(self):
|
|
273
|
+
"""One eager iteration; its phases are timed on CLOCK_MONOTONIC_RAW with a device sync after each (t_rollout, t_update)."""
|
|
274
|
+
if getattr(self, "graphs", None) is not None:
|
|
275
|
+
return self.iteration_captured()
|
|
276
|
+
self._sync(); t0 = raw_now()
|
|
277
|
+
v_last = self.rollout()
|
|
278
|
+
self._sync(); t1 = raw_now()
|
|
279
|
+
adv, ret = self.gae(v_last)
|
|
280
|
+
self.update(adv, ret)
|
|
281
|
+
self._sync(); t2 = raw_now()
|
|
282
|
+
self.it += 1
|
|
283
|
+
self.stats = dict(self._read_stats(), t_rollout=t1 - t0, t_update=t2 - t1)
|
|
284
|
+
return self.stats
|
|
285
|
+
|
|
286
|
+
# ------------------------------------------------------------------------------------------ W2b: the captured iteration
|
|
287
|
+
ENV_STATE = ("qpos", "qvel", "warm", "t", "a_prev", "et_timer")
|
|
288
|
+
|
|
289
|
+
def _tensors(self):
|
|
290
|
+
"""Every tensor an iteration reads or writes, by name (for snapshots: restored in place, so captured addresses hold)."""
|
|
291
|
+
d = {f"model.{k}": v for k, v in self.model.state_dict(keep_vars=True).items()}
|
|
292
|
+
for oi, o in enumerate(self.opts):
|
|
293
|
+
for pi, (p, st) in enumerate(o.state.items()):
|
|
294
|
+
for k, v in st.items():
|
|
295
|
+
if torch.is_tensor(v):
|
|
296
|
+
d[f"opt{oi}.{pi}.{k}"] = v
|
|
297
|
+
for k, v in self.buf.items():
|
|
298
|
+
d[f"buf.{k}"] = v
|
|
299
|
+
for name, rms in (("obs_rms", self.obs_rms), ("val_rms", self.val_rms)):
|
|
300
|
+
for k, v in rms.state_dict().items():
|
|
301
|
+
d[f"{name}.{k}"] = getattr(rms, k)
|
|
302
|
+
d["lr_t"] = self.lr_t
|
|
303
|
+
return d
|
|
304
|
+
|
|
305
|
+
def snapshot(self):
|
|
306
|
+
snap = {k: v.detach().clone() for k, v in self._tensors().items()}
|
|
307
|
+
snap.update({f"env.{k}": getattr(self.env, k).clone() for k in self.ENV_STATE})
|
|
308
|
+
snap["obs"] = self.obs.clone()
|
|
309
|
+
snap["rng"] = torch.cuda.get_rng_state() if self.dev.startswith("cuda") else torch.get_rng_state()
|
|
310
|
+
snap["it"] = self.it
|
|
311
|
+
return snap
|
|
312
|
+
|
|
313
|
+
@torch.no_grad()
|
|
314
|
+
def restore(self, snap):
|
|
315
|
+
for k, v in self._tensors().items():
|
|
316
|
+
v.data.copy_(snap[k])
|
|
317
|
+
for k in self.ENV_STATE:
|
|
318
|
+
cur = getattr(self.env, k)
|
|
319
|
+
if getattr(self, "S", None) is not None:
|
|
320
|
+
self.S[k].copy_(snap[f"env.{k}"]); setattr(self.env, k, self.S[k])
|
|
321
|
+
else:
|
|
322
|
+
setattr(self.env, k, snap[f"env.{k}"].clone())
|
|
323
|
+
if getattr(self, "S", None) is not None:
|
|
324
|
+
self.S["obs"].copy_(snap["obs"]); self.obs = self.S["obs"]
|
|
325
|
+
else:
|
|
326
|
+
self.obs = snap["obs"].clone()
|
|
327
|
+
self.env.frames = None
|
|
328
|
+
if self.lr_t.device.type != "cuda": # the CPU AdamW keeps its lr as a float (tests only)
|
|
329
|
+
for gr in self.opts[1].param_groups:
|
|
330
|
+
gr["lr"] = float(self.lr_t)
|
|
331
|
+
(torch.cuda.set_rng_state if self.dev.startswith("cuda") else torch.set_rng_state)(snap["rng"])
|
|
332
|
+
self.it = snap["it"]
|
|
333
|
+
|
|
334
|
+
def _bind_static(self):
|
|
335
|
+
for k in self.ENV_STATE:
|
|
336
|
+
setattr(self.env, k, self.S[k])
|
|
337
|
+
self.obs = self.S["obs"]
|
|
338
|
+
self.env.frames = None
|
|
339
|
+
|
|
340
|
+
def _rollout_body(self):
|
|
341
|
+
self._bind_static()
|
|
342
|
+
v_last = self.rollout()
|
|
343
|
+
adv, ret = self.gae(v_last)
|
|
344
|
+
for k in self.ENV_STATE:
|
|
345
|
+
self.S[k].copy_(getattr(self.env, k))
|
|
346
|
+
self.S["obs"].copy_(self.obs)
|
|
347
|
+
self.S["adv"].copy_(adv); self.S["ret"].copy_(ret)
|
|
348
|
+
|
|
349
|
+
def _update_body(self):
|
|
350
|
+
self.update(self.S["adv"], self.S["ret"])
|
|
351
|
+
self.S["stat"].copy_(self.stat_t)
|
|
352
|
+
|
|
353
|
+
def capture(self, warmup=2):
|
|
354
|
+
"""Capture the rollout (+ GAE) and the update as two CUDA graphs. Needs one eager iteration first (the optimisers' state).
|
|
355
|
+
The warm-up runs on a side stream mutate the state, so everything is snapshot before and restored in place after them:
|
|
356
|
+
the first replay is exactly the next iteration."""
|
|
357
|
+
assert self.dev.startswith("cuda") and self.it >= 1
|
|
358
|
+
R, n = self.cfg["rollouts"], self.env.n
|
|
359
|
+
self.S = {k: getattr(self.env, k).clone() for k in self.ENV_STATE}
|
|
360
|
+
self.S.update(obs=self.obs.clone(), adv=torch.zeros(R, n, device=self.dev), ret=torch.zeros(R, n, device=self.dev),
|
|
361
|
+
stat=torch.zeros(len(self.STAT_NAMES), device=self.dev))
|
|
362
|
+
snap = self.snapshot()
|
|
363
|
+
side = torch.cuda.Stream()
|
|
364
|
+
side.wait_stream(torch.cuda.current_stream())
|
|
365
|
+
with torch.cuda.stream(side):
|
|
366
|
+
for _ in range(warmup):
|
|
367
|
+
self._rollout_body(); self._update_body()
|
|
368
|
+
torch.cuda.current_stream().wait_stream(side)
|
|
369
|
+
torch.cuda.synchronize()
|
|
370
|
+
self.restore(snap)
|
|
371
|
+
for o in self.opts:
|
|
372
|
+
o.zero_grad(set_to_none=True)
|
|
373
|
+
torch.cuda.synchronize()
|
|
374
|
+
g_roll, g_upd = torch.cuda.CUDAGraph(), torch.cuda.CUDAGraph()
|
|
375
|
+
with torch.cuda.graph(g_roll):
|
|
376
|
+
self._rollout_body()
|
|
377
|
+
with torch.cuda.graph(g_upd, pool=g_roll.pool()):
|
|
378
|
+
self._update_body()
|
|
379
|
+
self._bind_static()
|
|
380
|
+
self.graphs = (g_roll, g_upd)
|
|
381
|
+
|
|
382
|
+
def iteration_captured(self):
|
|
383
|
+
g_roll, g_upd = self.graphs
|
|
384
|
+
self._sync(); t0 = raw_now()
|
|
385
|
+
g_roll.replay()
|
|
386
|
+
self._sync(); t1 = raw_now()
|
|
387
|
+
g_upd.replay()
|
|
388
|
+
self._sync(); t2 = raw_now()
|
|
389
|
+
self.it += 1
|
|
390
|
+
self.stats = dict(zip(self.STAT_NAMES, self.S["stat"].tolist()), t_rollout=t1 - t0, t_update=t2 - t1)
|
|
391
|
+
return self.stats
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
def raw_now():
|
|
395
|
+
return time.clock_gettime(time.CLOCK_MONOTONIC_RAW)
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"""Arm B (line 23, docs/training/campaigns/g1/seconds.md): our exact-gradient SAPO with residual PD actions on the G1 env of
|
|
2
|
+
g1_soft_env, through the engine's adjoint (g1_soft_grad.StepFn).
|
|
3
|
+
|
|
4
|
+
The algorithm is g1_tracking.G1Sapo's, transcribed (rollout_loss / targets / train_critic / update_alpha / iteration):
|
|
5
|
+
entropy-augmented BPTT return over an H-step window, the double critic (average for the actor's bootstrap, minimum for the
|
|
6
|
+
critic's target), td-lambda targets, the temperature's dual step. The knobs are the (RECIPES["e0"] and
|
|
7
|
+
docs/logs/env/fb_e0_mm_kit_sapo_s1.env.sh, with A1's critic): actor ActorSquashedMLP 1024-1024-512, critic EnsembleCritic 2 x
|
|
8
|
+
512-512 SiLU, AdamW (0.7, 0.95) actor 2e-3 / critic 5e-4 linear to 1e-5 over `decay_iters`, temperature AdamW 5e-3 from 0.1,
|
|
9
|
+
target entropy -0.5 per dim, actor and critic grad-norm clips 0.5, the per-env action-gradient clip at 2 x the median
|
|
10
|
+
(non-finite rows propagate and raise, as G1Sapo's), gamma 0.99, lambda 0.95, H 32, 4 critic iterations x 4 minibatches, the EMA
|
|
11
|
+
actor for evaluation (the LEARN_EMA decay min(0.999, (1 + n) / (10 + n))).
|
|
12
|
+
The env is arm A's (same observation, reward, terminations, residual map): the squashed action u in [-1, 1] is g1_soft_env's a, so
|
|
13
|
+
the setpoint is q_ref(t + 1) + half_range * u. Counted per window (the plan's guard on the unbounded self-pair derivatives, 11-10):
|
|
14
|
+
the envs whose action-gradient row is non-finite, and those the median clip scales down.
|
|
15
|
+
"""
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import copy
|
|
19
|
+
import math
|
|
20
|
+
|
|
21
|
+
import torch
|
|
22
|
+
import torch.nn as nn
|
|
23
|
+
from torch.nn.utils.clip_grad import clip_grad_norm_
|
|
24
|
+
|
|
25
|
+
from . import g1_soft_env as G
|
|
26
|
+
from . import g1_soft_grad as D
|
|
27
|
+
from .nets_shac import ActorSquashedMLP, EnsembleCritic, RunningMeanStd
|
|
28
|
+
|
|
29
|
+
CFG = dict(n_env=1024, H=32, gamma=0.99, lam=0.95, actor_lr=2e-3, critic_lr=5e-4, alpha_lr=5e-3, init_alpha=0.1,
|
|
30
|
+
target_entropy_per_dim=-0.5, actor_units=(1024, 1024, 512), critic_units=(512, 512), actor_clip=0.5, critic_clip=0.5,
|
|
31
|
+
action_grad_clip=2.0, critic_iterations=4, critic_minibatches=4, decay_iters=3000, reset_noise=0.02, ema=True)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class GradCounter:
|
|
35
|
+
"""The per-env action-gradient clip of E0 (shac_vec._clip_grad_per_env, as g1_tracking.clip_grad_per_env: no zeroing), with
|
|
36
|
+
counts: non-finite rows and rows scaled down, accumulated over a window on the device (no host sync)."""
|
|
37
|
+
|
|
38
|
+
def __init__(self, factor, device):
|
|
39
|
+
self.factor = factor
|
|
40
|
+
self.nonfinite = torch.zeros((), device=device)
|
|
41
|
+
self.clipped = torch.zeros((), device=device)
|
|
42
|
+
self.rows = torch.zeros((), device=device)
|
|
43
|
+
|
|
44
|
+
def __call__(self, g):
|
|
45
|
+
n = g.norm(dim=-1, keepdim=True)
|
|
46
|
+
fin = torch.isfinite(n)
|
|
47
|
+
med = torch.where(fin, n, torch.full_like(n, float("nan"))).nanmedian()
|
|
48
|
+
cap = self.factor * med
|
|
49
|
+
scale = torch.where(n > cap, cap / n, torch.ones_like(n))
|
|
50
|
+
self.nonfinite += (~fin).sum()
|
|
51
|
+
self.clipped += ((n > cap) & fin).sum()
|
|
52
|
+
self.rows += n.numel()
|
|
53
|
+
return g * scale
|
|
54
|
+
|
|
55
|
+
def read_and_zero(self):
|
|
56
|
+
out = dict(grad_nonfinite=float(self.nonfinite), grad_clipped=float(self.clipped), grad_rows=float(self.rows))
|
|
57
|
+
for t in (self.nonfinite, self.clipped, self.rows):
|
|
58
|
+
t.zero_()
|
|
59
|
+
return out
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def lr_linear(it, lr, decay):
|
|
63
|
+
return lr + (1e-5 - lr) * min(it / decay, 1.0)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class SapoG1:
|
|
67
|
+
def __init__(self, env, law, cfg=CFG, seed=0):
|
|
68
|
+
"""env: a g1_soft_env.G1SoftTrack whose backend is `law` (GpuLaw with slots >= H and tape=True, or CpuJacLaw)."""
|
|
69
|
+
torch.manual_seed(seed)
|
|
70
|
+
self.env, self.law, self.cfg = env, law, dict(cfg)
|
|
71
|
+
self.dev, self.N, self.H = env.dev, env.n, cfg["H"]
|
|
72
|
+
self.gen = torch.Generator(device=self.dev).manual_seed(seed)
|
|
73
|
+
env.reset(torch.ones(self.N, dtype=torch.bool, device=self.dev), self._starts(self.N))
|
|
74
|
+
obs = env.observe().float()
|
|
75
|
+
self.obs_dim = obs.shape[1]
|
|
76
|
+
self.actor = ActorSquashedMLP(self.obs_dim, G.NU, units=tuple(cfg["actor_units"]), activation="silu", device=self.dev)
|
|
77
|
+
self.critic = EnsembleCritic(self.obs_dim, units=tuple(cfg["critic_units"]), activation="silu", device=self.dev, n_critics=2)
|
|
78
|
+
self.actor_opt = torch.optim.AdamW(self.actor.parameters(), lr=cfg["actor_lr"], betas=(0.7, 0.95))
|
|
79
|
+
self.critic_opt = torch.optim.AdamW(self.critic.parameters(), lr=cfg["critic_lr"], betas=(0.7, 0.95))
|
|
80
|
+
self.log_alpha = nn.Parameter(torch.tensor(math.log(cfg["init_alpha"]), device=self.dev))
|
|
81
|
+
self.alpha_opt = torch.optim.AdamW([self.log_alpha], lr=cfg["alpha_lr"], betas=(0.7, 0.95))
|
|
82
|
+
self.target_entropy = float(cfg["target_entropy_per_dim"] * G.NU)
|
|
83
|
+
self._abs_H = abs(self.target_entropy)
|
|
84
|
+
self.obs_rms = RunningMeanStd(shape=(self.obs_dim,), device=self.dev)
|
|
85
|
+
self.ema = copy.deepcopy(self.actor) if cfg["ema"] else None
|
|
86
|
+
self.n_ema = 0
|
|
87
|
+
H, N = self.H, self.N
|
|
88
|
+
z = lambda *s: torch.zeros(*s, device=self.dev) # noqa: E731
|
|
89
|
+
self.cobs_buf, self.rew_buf, self.done_mask = z(H, N, self.obs_dim), z(H, N), z(H, N)
|
|
90
|
+
self.next_values, self.ent_buf, self.target_values = z(H, N), z(H, N), z(H, N)
|
|
91
|
+
self.grads = GradCounter(cfg["action_grad_clip"], self.dev)
|
|
92
|
+
self.it = 0
|
|
93
|
+
|
|
94
|
+
def _starts(self, k):
|
|
95
|
+
return torch.randint(0, self.env.m.T - 1, (k,), generator=self.gen, device=self.dev)
|
|
96
|
+
|
|
97
|
+
def _ent_norm(self, ent):
|
|
98
|
+
return (ent - self.target_entropy) / (2.0 * self._abs_H)
|
|
99
|
+
|
|
100
|
+
def _diff_step(self, k, u):
|
|
101
|
+
"""One differentiable control step of the env under the squashed action u: the engine through StepFn on tape slot k, then
|
|
102
|
+
the reward, terminations and observation on the step's own frames (all differentiable but the masks)."""
|
|
103
|
+
e = self.env
|
|
104
|
+
ctrl = e.lm.ctrl(e.setpoint(u.to(e.dt))).contiguous()
|
|
105
|
+
q1, v1, w1, xp, xq, xv, xa = D.step(self.law, k, e.qpos, e.qvel, ctrl, e.warm.detach(), e.foot)
|
|
106
|
+
e.t = (e.t + 1).clamp_max(e.m.T - 1)
|
|
107
|
+
fr = dict(xpos=xp, xquat=xq, xvel=xv, xangvel=xa)
|
|
108
|
+
r, _ = e.reward(fr, e.t)
|
|
109
|
+
az, ao, ee = e.fails({k_: v.detach() for k_, v in fr.items()}, e.t)
|
|
110
|
+
term = az | ao | ee
|
|
111
|
+
if e.early:
|
|
112
|
+
e.et_timer = torch.where(r.detach() < G.ET_REWARD, e.et_timer + 1, torch.zeros_like(e.et_timer))
|
|
113
|
+
term = term | (e.et_timer >= G.ET_STEPS)
|
|
114
|
+
nonfinite = ~torch.isfinite(q1.detach()).all(1) | ~torch.isfinite(v1.detach()).all(1)
|
|
115
|
+
tout = e.t >= e.m.T - 1
|
|
116
|
+
ue = u.to(e.dt)
|
|
117
|
+
e.qpos, e.qvel, e.warm, e.a_prev, e.frames = q1, v1, w1, ue, fr
|
|
118
|
+
obs = G.obs_phc(e.lm, e.tr, xp, xq, xv, xa, q1, v1, ue, e.ref((e.t + 1).clamp_max(e.m.T - 1)))
|
|
119
|
+
return obs.float(), r.float(), term | nonfinite, tout, nonfinite
|
|
120
|
+
|
|
121
|
+
def rollout_loss(self):
|
|
122
|
+
H, N, cfg, e = self.H, self.N, self.cfg, self.env
|
|
123
|
+
alpha = self.log_alpha.exp().detach()
|
|
124
|
+
o_rms = copy.deepcopy(self.obs_rms)
|
|
125
|
+
e.qpos, e.qvel = e.qpos.detach(), e.qvel.detach() # the window starts from the carried state, detached
|
|
126
|
+
e.a_prev = e.a_prev.detach()
|
|
127
|
+
e.frames = None
|
|
128
|
+
obs = e.observe().float()
|
|
129
|
+
self.obs_rms.update(obs)
|
|
130
|
+
rew_acc = torch.zeros(N, device=self.dev)
|
|
131
|
+
disc = torch.ones(N, device=self.dev)
|
|
132
|
+
loss = torch.zeros((), device=self.dev)
|
|
133
|
+
stats = dict(rew=0.0, done=0.0)
|
|
134
|
+
for i in range(H):
|
|
135
|
+
self.cobs_buf[i] = o_rms.normalize(obs).detach()
|
|
136
|
+
dist = self.actor.distribution(o_rms.normalize(obs))
|
|
137
|
+
u = dist.rsample()
|
|
138
|
+
u.register_hook(self.grads)
|
|
139
|
+
ent = dist.entropy().sum(-1)
|
|
140
|
+
obs, r, term, tout, nonfin = self._diff_step(i, u)
|
|
141
|
+
done = term | tout
|
|
142
|
+
self.obs_rms.update(obs.detach())
|
|
143
|
+
v_min, v_avg = self.critic(o_rms.normalize(obs), return_type="min_and_avg")
|
|
144
|
+
boot = tout & ~term # the clip's end: bootstrap from the state reached
|
|
145
|
+
nv_avg = torch.where(done, torch.where(boot, v_avg.squeeze(-1), torch.zeros_like(r)), v_avg.squeeze(-1))
|
|
146
|
+
nv_min = torch.where(done, torch.where(boot, v_min.squeeze(-1), torch.zeros_like(r)), v_min.squeeze(-1))
|
|
147
|
+
rew_acc = rew_acc + disc * (r + alpha * self._ent_norm(ent))
|
|
148
|
+
if i < H - 1:
|
|
149
|
+
loss = loss + ((-rew_acc - cfg["gamma"] * disc * nv_avg) * done.float()).sum()
|
|
150
|
+
else:
|
|
151
|
+
loss = loss + (-rew_acc - cfg["gamma"] * disc * nv_avg).sum()
|
|
152
|
+
disc = torch.where(done, torch.ones_like(disc), disc * cfg["gamma"])
|
|
153
|
+
rew_acc = torch.where(done, torch.zeros_like(rew_acc), rew_acc)
|
|
154
|
+
with torch.no_grad():
|
|
155
|
+
self.rew_buf[i] = r.detach()
|
|
156
|
+
self.done_mask[i] = done.float() if i < H - 1 else torch.ones_like(r)
|
|
157
|
+
self.next_values[i] = nv_min.detach()
|
|
158
|
+
self.ent_buf[i] = ent.detach()
|
|
159
|
+
stats["rew"] += r.detach().mean() / H
|
|
160
|
+
stats["done"] += done.float().mean() / H
|
|
161
|
+
if bool(done.any()): # one host read per step (eager); worlds restart detached
|
|
162
|
+
noise = cfg["reset_noise"] * torch.randn(N, G.NU, generator=self.gen, device=self.dev).to(e.dt)
|
|
163
|
+
e.qpos, e.qvel = torch.where(done.view(-1, 1), e.qpos.detach(), e.qpos), torch.where(done.view(-1, 1), e.qvel.detach(), e.qvel)
|
|
164
|
+
e.reset(done, self._starts(N), q_noise=noise)
|
|
165
|
+
obs = torch.where(done.view(-1, 1), e.observe().float(), obs)
|
|
166
|
+
return loss / (H * N), {k: float(v) for k, v in stats.items()}
|
|
167
|
+
|
|
168
|
+
@torch.no_grad()
|
|
169
|
+
def targets(self):
|
|
170
|
+
alpha, lam_c, g = self.log_alpha.exp(), self.cfg["lam"], self.cfg["gamma"]
|
|
171
|
+
Ai = torch.zeros(self.N, device=self.dev)
|
|
172
|
+
Bi = torch.zeros(self.N, device=self.dev)
|
|
173
|
+
lam = torch.ones(self.N, device=self.dev)
|
|
174
|
+
ent = self._ent_norm(self.ent_buf)
|
|
175
|
+
for i in reversed(range(self.H)):
|
|
176
|
+
lam = lam * lam_c * (1.0 - self.done_mask[i]) + self.done_mask[i]
|
|
177
|
+
rew = self.rew_buf[i] + alpha * ent[i]
|
|
178
|
+
Ai = (1.0 - self.done_mask[i]) * (lam_c * g * Ai + g * self.next_values[i] + (1.0 - lam) / (1.0 - lam_c) * rew)
|
|
179
|
+
Bi = g * (self.next_values[i] * self.done_mask[i] + Bi * (1.0 - self.done_mask[i])) + rew
|
|
180
|
+
self.target_values[i] = (1.0 - lam_c) * Ai + lam * Bi
|
|
181
|
+
|
|
182
|
+
def train_critic(self):
|
|
183
|
+
x, y = self.cobs_buf.reshape(-1, self.obs_dim), self.target_values.reshape(-1)
|
|
184
|
+
n = x.shape[0]
|
|
185
|
+
bs = n // self.cfg["critic_minibatches"]
|
|
186
|
+
tot = torch.zeros((), device=self.dev)
|
|
187
|
+
for _ in range(self.cfg["critic_iterations"]):
|
|
188
|
+
perm = torch.randperm(n, generator=self.gen, device=self.dev)
|
|
189
|
+
for s in range(0, n - bs + 1, bs):
|
|
190
|
+
idx = perm[s:s + bs]
|
|
191
|
+
self.critic_opt.zero_grad()
|
|
192
|
+
l = ((self.critic(x[idx], return_type="all").squeeze(-1) - y[idx][None]) ** 2).mean()
|
|
193
|
+
l.backward()
|
|
194
|
+
clip_grad_norm_(self.critic.parameters(), self.cfg["critic_clip"])
|
|
195
|
+
self.critic_opt.step()
|
|
196
|
+
tot += l.detach()
|
|
197
|
+
return float(tot) / (self.cfg["critic_iterations"] * self.cfg["critic_minibatches"])
|
|
198
|
+
|
|
199
|
+
def update_alpha(self):
|
|
200
|
+
loss = (self.log_alpha.exp() * self._abs_H * (self.ent_buf - self.target_entropy)).mean()
|
|
201
|
+
self.alpha_opt.zero_grad()
|
|
202
|
+
loss.backward()
|
|
203
|
+
clip_grad_norm_([self.log_alpha], 0.5)
|
|
204
|
+
self.alpha_opt.step()
|
|
205
|
+
|
|
206
|
+
def iteration(self):
|
|
207
|
+
cfg = self.cfg
|
|
208
|
+
for o, v in ((self.actor_opt, lr_linear(self.it, cfg["actor_lr"], cfg["decay_iters"])),
|
|
209
|
+
(self.critic_opt, lr_linear(self.it, cfg["critic_lr"], cfg["decay_iters"]))):
|
|
210
|
+
for g in o.param_groups:
|
|
211
|
+
g["lr"] = v
|
|
212
|
+
sync = torch.cuda.synchronize if str(self.dev).startswith("cuda") else (lambda: None)
|
|
213
|
+
clock = lambda: __import__("time").clock_gettime(__import__("time").CLOCK_MONOTONIC_RAW) # noqa: E731
|
|
214
|
+
sync(); t0 = clock()
|
|
215
|
+
self.actor_opt.zero_grad()
|
|
216
|
+
loss, stats = self.rollout_loss()
|
|
217
|
+
sync(); t1 = clock()
|
|
218
|
+
loss.backward()
|
|
219
|
+
sync(); t2 = clock()
|
|
220
|
+
gn = clip_grad_norm_(self.actor.parameters(), cfg["actor_clip"])
|
|
221
|
+
if not torch.isfinite(gn):
|
|
222
|
+
raise ValueError(f"non-finite actor grad norm at iteration {self.it}: {self.grads.read_and_zero()}")
|
|
223
|
+
self.actor_opt.step()
|
|
224
|
+
if self.ema is not None:
|
|
225
|
+
self.n_ema += 1
|
|
226
|
+
d = min(0.999, (1 + self.n_ema) / (10 + self.n_ema))
|
|
227
|
+
with torch.no_grad():
|
|
228
|
+
for pe, pa in zip(self.ema.parameters(), self.actor.parameters()):
|
|
229
|
+
pe.mul_(d).add_(pa, alpha=1 - d)
|
|
230
|
+
self.update_alpha()
|
|
231
|
+
self.targets()
|
|
232
|
+
vloss = self.train_critic()
|
|
233
|
+
sync(); t3 = clock()
|
|
234
|
+
self.it += 1
|
|
235
|
+
stats.update(t_rollout=t1 - t0, t_backward=t2 - t1, t_rest=t3 - t2)
|
|
236
|
+
return dict(stats, loss=float(loss.detach()), gn=float(gn), vloss=vloss, alpha=float(self.log_alpha.detach().exp()),
|
|
237
|
+
ent=float(self.ent_buf.mean()), **self.grads.read_and_zero())
|
|
238
|
+
|
|
239
|
+
def eval_actor(self):
|
|
240
|
+
return self.ema if self.ema is not None else self.actor
|