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,622 @@
|
|
|
1
|
+
"""Arm A2's PPO: InstantMimic's side_kick_hpo training rules for the G1 BeyondMimic side kick (a2-beyondmimic-spec.md, section
|
|
2
|
+
"PPO as configured by side_kick_hpo"), driving the A2 env (a2-env-interface.md, g1_bm_env.BMTrack).
|
|
3
|
+
|
|
4
|
+
Every rule is cited to InstantMimic 947430ee. IM = ~/data/oneclip/lit/repos/instantmimic_src; C = IM/config/unitree_g1/beyondmimic;
|
|
5
|
+
S = IM/src/instantmimic. The config chain is side_kick_hpo -> side_kick -> side_kick_reference -> base; only base and hpo set
|
|
6
|
+
agent / models keys (side_kick.yaml:1-21 and side_kick_reference.yaml:1-7 set env, experiment and runtime only).
|
|
7
|
+
|
|
8
|
+
Configuration (C/base.yaml:84-133 overridden by C/side_kick_hpo.yaml:7-36):
|
|
9
|
+
rollouts 16 (hpo:20), epochs 3 (hpo:25), mini_batches 4 (base:113), shuffle per_update (base:118), gamma 0.99 (base:107),
|
|
10
|
+
GAE lambda 0.82 (hpo:26), ratio clip 0.175 (hpo:28), value clip 0.2 with clip_predicted_values and mode max (base:115-117),
|
|
11
|
+
value scale 1.0 (base:121), entropy 0.015 (hpo:27), grad-norm clip 50 (hpo:24) per actor / critic group (the env flag,
|
|
12
|
+
S/envs/unitree_g1/tasks/beyondmimic_tracking/beyondmimic_tracking_env.py:109-112, read by S/rl/factory.py:105-119),
|
|
13
|
+
lr 1.37e-4 in [1e-5, 4e-4] (hpo:21-23), KL-adaptive with threshold 0.01, factor 1.5, per_minibatch (base:128-132),
|
|
14
|
+
analytic KL (base:133), time-limit bootstrap (base:108), RslRlEmpiricalNormalization on states, no value preprocessor
|
|
15
|
+
(base:110-111), rsl_rl init (base:119), separate MLPs (base:85), ELU, no normalisation, actor 512-256-128, critic 640-320-160
|
|
16
|
+
(hpo:30-36), sigma a direct parameter (std: parameter, parameterization: scalar), initial log std 0, log-std bounds
|
|
17
|
+
+-13.8155 = log(1e-6), log(1e6) with clamp, no action transform (base:91-97); runtime precision float32 (side_kick.yaml:21).
|
|
18
|
+
Optimiser muon with momentum 0.95, nesterov, match_rms_adamw, ns 5, eps 1e-7, weight decay 3e-5 and the AdamW companion
|
|
19
|
+
betas (0.9, 0.999), eps 2e-5, weight decay 3e-5 (hpo:8-19, lowered by S/rl/build_specs.py:331-366).
|
|
20
|
+
|
|
21
|
+
Rules, in the order an iteration runs them:
|
|
22
|
+
- Observations: the agent input is [actor 160 | critic 286] (S/rl/runtime.py:84-104); the actor MLP reads [:160], the critic
|
|
23
|
+
[160:446] (S/rl/models/actor_critic.py:368-378).
|
|
24
|
+
- Normaliser: RSL-RL empirical moments over the 446 inputs, (x - mean) / (std + 0.01), no clip
|
|
25
|
+
(S/rl/normalization.py:223-319). It is updated once per env step with that step's post-step observation buf.obs[k+1]
|
|
26
|
+
(S/train/rollout.py:762-778), which for a done world is its fresh episode's first observation. Neither the reset
|
|
27
|
+
observation that seeds the run (S/train/runtime.py:858-862) nor any terminal observation updates it.
|
|
28
|
+
- Act (S/rl/ppo/agent.py:1639-1680; S/rl/models/actor_critic.py:1086-1129): normalise the current raw observation with the
|
|
29
|
+
current moments, keep that normalised input for the update (policy-input snapshot, normalization.py:240-243 and
|
|
30
|
+
agent.py:3511-3533), a = mean + sigma * eps, value from the critic.
|
|
31
|
+
- Step order after env.step (S/train/rollout.py:776-782): dones = terminated | truncated; the normaliser update with the new
|
|
32
|
+
observation; then the time-out bootstrap V(terminal critic obs), normalised with the moments that include this step's update
|
|
33
|
+
(rollout.py:862-920, agent.py:3351-3361, 1742-1780), kept only where the time-out mask is set (agent.py:3340-3349).
|
|
34
|
+
- End of the rollout phase (IM: the start of its update, agent.py:3363-3404; nothing changes in between and no random number
|
|
35
|
+
is drawn, so the arithmetic is the same and the rollout graph ends with the advantages): last value from buf.obs[R];
|
|
36
|
+
rewards + gamma * bootstrap values; GAE and one advantage normalisation over the whole rollout,
|
|
37
|
+
(A - mean) / (std(correction 1) + 1e-8), returns = A_raw + V (agent.py:250-313).
|
|
38
|
+
- Update (agent.py:4643-4676, 4630-4637, 4223-4402):
|
|
39
|
+
old log sigma snapshot (agent.py:3834-3845); one permutation per update (agent.py:3581-3594, 3645-3650); the shuffled views (agent.py:3652-3705); the old log-probabilities and old means recomputed through the update path per
|
|
40
|
+
minibatch before any step, so an unchanged policy starts at ratio 1 and KL 0 (agent.py:3108-3163);
|
|
41
|
+
then 3 epochs x 4 minibatches of: evaluate (actor_critic.py:754-806, distributions.py:19-73), analytic KL(old || new)
|
|
42
|
+
(agent.py:106-121, 3847-3874), the loss terms (S/learning/losses.py:33-71), the KL learning-rate rule BEFORE this
|
|
43
|
+
minibatch's step (agent.py:3281-3285, tensor branch 1871-1930), zero_grad, backward of policy + value + entropy
|
|
44
|
+
(agent.py:3291-3301), the per-group grad-norm clip (agent.py:3305, 2921-2951, groups actor_critic.py:395-420), Muon then AdamW
|
|
45
|
+
(S/rl/optimizers.py:734-747).
|
|
46
|
+
- Muon on exactly the parameters S/rl/optimizers.py:23-24, 53-63, 79-93 selects (here actor_trunk.{2,4}.weight and
|
|
47
|
+
trunk.{2,4}.weight), AdamW on every other trainable parameter including sigma (one group, decay_vector_parameters default
|
|
48
|
+
True, optimizers.py:129-146, 149-158, 228-307). Optimiser state is materialised at construction without a step
|
|
49
|
+
(agent.py:2709-2808).
|
|
50
|
+
- Network init: built on the CPU in float32 in IM's registration order, then the CPU RNG state taken at entry is restored and
|
|
51
|
+
the Linear layers re-initialised in RSL-RL order actor_trunk, policy_head, trunk, value_head (actor_critic.py:81-83,
|
|
52
|
+
199-232, 274-297, 313-328); then moved to the env's device and dtype.
|
|
53
|
+
- Network matmuls run with TF32 ("high") on CUDA (S/utils/network_precision.py:69-85, agent.py:1470-1474, 1655-1658,
|
|
54
|
+
1721-1757, 4639-4641); the env step stays IEEE.
|
|
55
|
+
|
|
56
|
+
Deviations, each numerically neutral or forced:
|
|
57
|
+
1. Random streams: action noise from torch.randn and the permutation from argsort(torch.rand) (their randperm: the same law), both on the default generator of the
|
|
58
|
+
device. IM draws noise with a counter-based Warp kernel on CUDA (agent.py:1433-1467) and the permutation from a captured
|
|
59
|
+
generator (agent.py:3596-3616). Same distributions, different streams.
|
|
60
|
+
2. Muon's Newton-Schulz runs eager (IM torch.compile's it on CUDA, optimizers.py:396-425): same math, possibly other rounding.
|
|
61
|
+
g1_ppo.CapturableMuon ports IM's single-tensor path; IM batches equal-shaped matrices (optimizers.py:544-577), so the four
|
|
62
|
+
Muon matrices are asserted to have distinct shapes (they do).
|
|
63
|
+
3. One lr tensor shared by Muon and AdamW, updated once per minibatch. IM keeps two tensors (optimizers.py:255-274) and applies
|
|
64
|
+
the same rule to each group (agent.py:1871-1930), so the two always hold the same value.
|
|
65
|
+
4. IM casts the update-path tensors and the loss inputs to float32 (agent.py:3217-3223, 3251-3254). These casts are no-ops in
|
|
66
|
+
float32 training and are left out, so f64 CPU tests stay f64. The analytic KL keeps IM's float32 cast (it only feeds the
|
|
67
|
+
float32 lr rule).
|
|
68
|
+
5. On the CPU (tests only) torch refuses a capturable AdamW, so it holds a float lr refreshed from the lr tensor before each of
|
|
69
|
+
its steps (a host read of a CPU tensor) and reads its own step counter on the host. On CUDA AdamW is capturable and reads
|
|
70
|
+
the device lr tensor (IM's update_cuda_graph path).
|
|
71
|
+
6. The TF32 scope is entered on CUDA only. IM's setter is process-wide, but it has no effect for float64 or CPU tensors.
|
|
72
|
+
7. IM's action_mean_scale (ones) and action_log_std_scale (zeros) buffers are left out: x * 1 and x + 0 are exact. They change
|
|
73
|
+
only through an ActionScaleSnapshot, which the direct G1 control does not provide (S/envs/direct_rl_env.py:3580-3587).
|
|
74
|
+
8. The act-time log-probability and mean are not stored: IM's recompute overwrites both before any use (agent.py:3108-3163).
|
|
75
|
+
9. The time-out mask is the env's `truncated`, which g1_bm_env sends RAW as IM's (reference.py:385, optimized_kernels.py:555/590
|
|
76
|
+
via rollout.py:965-975): a world that also terminated on its time-out step is bootstrapped too.
|
|
77
|
+
10. snapshot() / restore() use env.snapshot() / env.restore(snap); capture() uses env.make_static() / bind_static(S) /
|
|
78
|
+
copy_into(S).
|
|
79
|
+
|
|
80
|
+
The captured iteration (capture(), as g1_ppo.PPO.capture): after one eager iteration, the env's state is moved to static tensors,
|
|
81
|
+
everything is snapshot, `warmup` iterations run on a side stream, the snapshot is restored in place, then the rollout (+ GAE) is
|
|
82
|
+
captured as one CUDA graph and the update as a second in the first's pool; iteration() then replays them. The agent's own state is
|
|
83
|
+
allocated once and only written in place, so its addresses are static without copies. Random draws use the default CUDA generator,
|
|
84
|
+
whose philox offset a graph replay advances as the eager ops do.
|
|
85
|
+
|
|
86
|
+
Host synchronisation in iteration(), eager or captured: a device synchronize after each phase for the phase clocks (outside the
|
|
87
|
+
graphs) and the one read of the stats vector after the phases. Nothing inside the phases reads a device value on the host: the KL
|
|
88
|
+
lr rule, the normaliser, the advantage normalisation and the grad clip are device arithmetic without Python branches on tensors
|
|
89
|
+
(on the CPU, see 5).
|
|
90
|
+
"""
|
|
91
|
+
from __future__ import annotations
|
|
92
|
+
|
|
93
|
+
import contextlib
|
|
94
|
+
import math
|
|
95
|
+
|
|
96
|
+
import torch
|
|
97
|
+
import torch.nn as nn
|
|
98
|
+
import torch.nn.functional as F
|
|
99
|
+
|
|
100
|
+
from .g1_ppo import CapturableMuon, raw_now
|
|
101
|
+
|
|
102
|
+
BM_CFG = dict(
|
|
103
|
+
rollouts=16, epochs=3, minibatches=4, gamma=0.99, lam=0.82, ratio_clip=0.175, value_clip=0.2, value_scale=1.0, entropy=0.015,
|
|
104
|
+
grad_clip=50.0, lr=0.000137, lr_bounds=(1.0e-5, 4.0e-4), kl_threshold=0.01, kl_factor=1.5, actor_layers=(512, 256, 128),
|
|
105
|
+
critic_layers=(640, 320, 160), initial_log_std=0.0, log_std_bounds=(-13.815510557964274, 13.815510557964274), norm_eps=1.0e-2,
|
|
106
|
+
adv_eps=1e-08, muon=dict(momentum=0.95, nesterov=True, ns_steps=5, eps=1.0e-7, weight_decay=3.0e-5, adjust_lr_fn="match_rms_adamw"),
|
|
107
|
+
adamw=dict(betas=(0.9, 0.999), eps=2.0e-5, weight_decay=3.0e-5, amsgrad=False))
|
|
108
|
+
|
|
109
|
+
LOG_2PI_HALF = 0.5 * math.log(2.0 * math.pi) # S/rl/models/distributions.py:13-15
|
|
110
|
+
NORMAL_ENTROPY_CONST = LOG_2PI_HALF + 0.5
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
# ----------------------------------------------------------------------------------------------------------- pure rules
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def ppo_loss_terms(new_log_probs, old_log_probs, predicted_values, old_values, returns, advantages, entropy, cfg):
|
|
117
|
+
"""S/learning/losses.py:33-71 with clip_predicted_values=True and value_loss_clip_mode="max": the policy loss clips the log
|
|
118
|
+
ratio at log(1 +- clip) by the sign of the advantage before exponentiating; the value loss is the max of the unclipped and the
|
|
119
|
+
clipped squared errors; the entropy loss is -scale * mean(per-sample entropy). Returns (policy, value, entropy, clip fraction)."""
|
|
120
|
+
log_ratio = new_log_probs - old_log_probs
|
|
121
|
+
ratio = log_ratio.detach().exp()
|
|
122
|
+
clip_fraction = ((ratio - 1.0).abs() > cfg["ratio_clip"]).float().mean()
|
|
123
|
+
log_upper = math.log1p(cfg["ratio_clip"])
|
|
124
|
+
log_lower = math.log1p(-cfg["ratio_clip"])
|
|
125
|
+
objective_log_ratio = torch.where(advantages >= 0.0, log_ratio.clamp(max=log_upper), log_ratio.clamp(min=log_lower))
|
|
126
|
+
policy_loss = -(advantages * objective_log_ratio.exp()).mean()
|
|
127
|
+
clipped_values = old_values + (predicted_values - old_values).clamp(-cfg["value_clip"], cfg["value_clip"])
|
|
128
|
+
clipped_error = F.mse_loss(returns, clipped_values, reduction="none")
|
|
129
|
+
unclipped_error = F.mse_loss(returns, predicted_values, reduction="none")
|
|
130
|
+
value_loss = cfg["value_scale"] * torch.maximum(unclipped_error, clipped_error).mean()
|
|
131
|
+
entropy_loss = -cfg["entropy"] * entropy.mean()
|
|
132
|
+
return policy_loss, value_loss, entropy_loss, clip_fraction
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def diagonal_gaussian_kl_mean(old_mean, old_log_std, new_mean, new_log_std):
|
|
136
|
+
"""S/rl/ppo/agent.py:106-121 verbatim: KL(old || new) of diagonal Gaussians in float32, summed over dimensions, batch mean."""
|
|
137
|
+
old_mean = old_mean.float()
|
|
138
|
+
new_mean = new_mean.float()
|
|
139
|
+
old_log_std = old_log_std.float().expand_as(old_mean)
|
|
140
|
+
new_log_std = new_log_std.float().expand_as(new_mean)
|
|
141
|
+
log_std_delta = new_log_std - old_log_std
|
|
142
|
+
old_to_new_var_ratio = torch.exp(2.0 * (old_log_std - new_log_std))
|
|
143
|
+
mean_delta_term = (old_mean - new_mean).square() * torch.exp(-2.0 * new_log_std)
|
|
144
|
+
kl_per_dim = log_std_delta + 0.5 * (old_to_new_var_ratio + mean_delta_term) - 0.5
|
|
145
|
+
return kl_per_dim.sum(dim=-1, keepdim=True).mean()
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def lr_schedule_constants(cfg, device):
|
|
149
|
+
"""The schedule's device scalars in the lr dtype float32 (agent.py:1823-1869): kl_high = 2 threshold, kl_low = threshold / 2."""
|
|
150
|
+
th = cfg["kl_threshold"]
|
|
151
|
+
vals = dict(kl_high=th * 2.0, kl_low=th / 2.0, factor=cfg["kl_factor"], min_lr=cfg["lr_bounds"][0], max_lr=cfg["lr_bounds"][1])
|
|
152
|
+
return {k: torch.zeros((), device=device, dtype=torch.float32).fill_(float(v)) for k, v in vals.items()}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@torch.no_grad()
|
|
156
|
+
def kl_adaptive_lr_(lr_t, kl, c):
|
|
157
|
+
"""agent.py:1911-1930, the per_minibatch tensor branch: lr / factor (floored) if KL > kl_high, lr * factor (capped) if
|
|
158
|
+
0 < KL < kl_low, else unchanged. In place on the 0-dim lr tensor; no host read."""
|
|
159
|
+
kl = kl.to(device=lr_t.device, dtype=lr_t.dtype)
|
|
160
|
+
decreased = torch.maximum(lr_t / c["factor"], c["min_lr"])
|
|
161
|
+
increased = torch.minimum(lr_t * c["factor"], c["max_lr"])
|
|
162
|
+
increase_condition = (kl < c["kl_low"]) & (kl > 0.0)
|
|
163
|
+
lr_t.copy_(torch.where(kl > c["kl_high"], decreased, torch.where(increase_condition, increased, lr_t)))
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
@torch.no_grad()
|
|
167
|
+
def gae_(rewards, values, dones, last_values, advantages, returns, gamma, lam, adv_eps):
|
|
168
|
+
"""agent.py:291-313 (the torch path; the CUDA Warp kernel agent.py:124-151 computes the same formula). Tensors [R, n, 1];
|
|
169
|
+
writes the raw returns and the normalised advantages in place."""
|
|
170
|
+
R = rewards.shape[0]
|
|
171
|
+
advantage = torch.zeros_like(last_values)
|
|
172
|
+
for i in reversed(range(R)):
|
|
173
|
+
next_values = values[i + 1] if i < R - 1 else last_values
|
|
174
|
+
advantage = rewards[i] - values[i] + gamma * (1.0 - dones[i]) * (next_values + lam * advantage)
|
|
175
|
+
advantages[i].copy_(advantage)
|
|
176
|
+
returns.copy_(advantages + values)
|
|
177
|
+
advantages.sub_(advantages.mean()).div_(advantages.std(correction=1 if advantages.numel() > 1 else 0) + adv_eps)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@torch.no_grad()
|
|
181
|
+
def clip_group_grad_norm_(parameters, max_norm, device):
|
|
182
|
+
"""agent.py:2936-2951: one group's L2 norm accumulated parameter by parameter, scaled by min(max_norm / (norm + 1e-6), 1)."""
|
|
183
|
+
grads = [p.grad for p in parameters if p.grad is not None]
|
|
184
|
+
total_norm_sq = torch.zeros((), device=device)
|
|
185
|
+
for grad in grads:
|
|
186
|
+
total_norm_sq = total_norm_sq + torch.sum(grad * grad)
|
|
187
|
+
total_norm = torch.sqrt(total_norm_sq)
|
|
188
|
+
clip_coef = torch.clamp(max_norm / (total_norm + 1e-06), max=1.0)
|
|
189
|
+
for grad in grads:
|
|
190
|
+
grad.mul_(clip_coef)
|
|
191
|
+
return total_norm
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def _trunk_module_index(name):
|
|
195
|
+
parts = name.split(".")
|
|
196
|
+
if not parts or parts[-1] != "weight":
|
|
197
|
+
return None
|
|
198
|
+
for index, part in enumerate(parts[:-1]):
|
|
199
|
+
if (part == "trunk" or part.endswith("_trunk")) and index + 1 < len(parts) - 1 and parts[index + 1].isdigit():
|
|
200
|
+
return int(parts[index + 1])
|
|
201
|
+
return None
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def is_muon_hidden_layer_param(name, param):
|
|
205
|
+
"""S/rl/optimizers.py:23-24, 53-63, 79-93: a trainable 2-D matrix with both sides > 1, not in a *head, at a trunk index > 0
|
|
206
|
+
(the residual-block rule of optimizers.py:66-76 cannot match these MLP names)."""
|
|
207
|
+
if not (param.requires_grad and param.ndim == 2 and min(param.shape) > 1):
|
|
208
|
+
return False
|
|
209
|
+
parts = name.split(".")
|
|
210
|
+
if len(parts) >= 2 and parts[-2].endswith("head"):
|
|
211
|
+
return False
|
|
212
|
+
idx = _trunk_module_index(name)
|
|
213
|
+
return idx is not None and idx > 0
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
# ----------------------------------------------------------------------------------------------------------- modules
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class EmpiricalNorm(nn.Module):
|
|
220
|
+
"""S/rl/normalization.py:223-319 (RslRlEmpiricalNormalization, epsilon 1e-2), in the env's dtype (IM: float32). The rate is
|
|
221
|
+
the integer count ratio, which true division makes a default-dtype (float32) scalar, as in IM."""
|
|
222
|
+
|
|
223
|
+
def __init__(self, dim, device, dtype, eps):
|
|
224
|
+
super().__init__()
|
|
225
|
+
self.eps = float(eps)
|
|
226
|
+
self.register_buffer("running_mean", torch.zeros(dim, device=device, dtype=dtype))
|
|
227
|
+
self.register_buffer("running_variance", torch.ones(dim, device=device, dtype=dtype))
|
|
228
|
+
self.register_buffer("running_std", torch.ones(dim, device=device, dtype=dtype))
|
|
229
|
+
self.register_buffer("current_count", torch.zeros((), device=device, dtype=torch.long))
|
|
230
|
+
|
|
231
|
+
@torch.no_grad()
|
|
232
|
+
def update(self, x):
|
|
233
|
+
assert x.dim() == 2 and x.shape[1] == self.running_mean.shape[0], x.shape
|
|
234
|
+
count_x = x.shape[0]
|
|
235
|
+
self.current_count.add_(count_x)
|
|
236
|
+
rate = count_x / self.current_count
|
|
237
|
+
input_var = torch.var(x, dim=0, unbiased=False)
|
|
238
|
+
input_mean = torch.mean(x, dim=0)
|
|
239
|
+
delta_mean = input_mean - self.running_mean
|
|
240
|
+
self.running_mean.add_(rate * delta_mean)
|
|
241
|
+
self.running_variance.add_(rate * (input_var - self.running_variance + delta_mean * (input_mean - self.running_mean)))
|
|
242
|
+
self.running_std.copy_(torch.sqrt(self.running_variance))
|
|
243
|
+
|
|
244
|
+
def forward(self, x, cols=slice(None)):
|
|
245
|
+
"""Normalise x, whose features are columns `cols` of the 446 (elementwise, so a slice equals slicing the full output)."""
|
|
246
|
+
return (x - self.running_mean[cols]) / (self.running_std[cols] + self.eps)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def _mlp(in_dim, layers):
|
|
250
|
+
"""S/rl/models/actor_critic_shared.py:83-120 (mlp, no norm): Linear, ELU per hidden layer."""
|
|
251
|
+
mods, d = [], int(in_dim)
|
|
252
|
+
for h in layers:
|
|
253
|
+
mods += [nn.Linear(d, int(h)), nn.ELU()]
|
|
254
|
+
d = int(h)
|
|
255
|
+
return nn.Sequential(*mods)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
class BMActorCritic(nn.Module):
|
|
259
|
+
"""IM's ActorCritic as side_kick_hpo builds it (separate, asymmetric, std parameter in scalar parameterization, rsl_rl init),
|
|
260
|
+
with IM's module names so its optimiser split and gradient groups apply unchanged."""
|
|
261
|
+
|
|
262
|
+
def __init__(self, actor_obs_dim, critic_obs_dim, act_dim, cfg):
|
|
263
|
+
super().__init__()
|
|
264
|
+
self.actor_obs_dim, self.critic_obs_dim, self.act_dim = int(actor_obs_dim), int(critic_obs_dim), int(act_dim)
|
|
265
|
+
self.min_log_std, self.max_log_std = (float(v) for v in cfg["log_std_bounds"])
|
|
266
|
+
rng = torch.get_rng_state() # actor_critic.py:81-83
|
|
267
|
+
self.trunk = _mlp(self.critic_obs_dim, cfg["critic_layers"]) # registration order: actor_critic.py:199-232
|
|
268
|
+
self.actor_trunk = _mlp(self.actor_obs_dim, cfg["actor_layers"])
|
|
269
|
+
self.value_head = nn.Linear(int(cfg["critic_layers"][-1]), 1)
|
|
270
|
+
self.policy_head = nn.Linear(int(cfg["actor_layers"][-1]), self.act_dim)
|
|
271
|
+
self.log_std = nn.Parameter(torch.full((self.act_dim,), math.exp(float(cfg["initial_log_std"])))) # holds sigma (289-297)
|
|
272
|
+
assert all(p.device.type == "cpu" and p.dtype == torch.float32 for p in self.parameters())
|
|
273
|
+
torch.set_rng_state(rng) # RSL-RL order: actor_critic.py:313-328
|
|
274
|
+
for m in self.actor_trunk.modules():
|
|
275
|
+
if isinstance(m, nn.Linear):
|
|
276
|
+
m.reset_parameters()
|
|
277
|
+
self.policy_head.reset_parameters()
|
|
278
|
+
for m in self.trunk.modules():
|
|
279
|
+
if isinstance(m, nn.Linear):
|
|
280
|
+
m.reset_parameters()
|
|
281
|
+
self.value_head.reset_parameters()
|
|
282
|
+
|
|
283
|
+
def physical_log_std(self):
|
|
284
|
+
"""actor_critic.py:511-522: log(clamp(sigma, e^min, e^max))."""
|
|
285
|
+
return torch.log(self.log_std.clamp(min=math.exp(self.min_log_std), max=math.exp(self.max_log_std)))
|
|
286
|
+
|
|
287
|
+
def actor_mean(self, obs_actor):
|
|
288
|
+
return self.policy_head(self.actor_trunk(obs_actor))
|
|
289
|
+
|
|
290
|
+
def value(self, obs_critic):
|
|
291
|
+
return self.value_head(self.trunk(obs_critic))
|
|
292
|
+
|
|
293
|
+
def _split(self, obs):
|
|
294
|
+
a, c = self.actor_obs_dim, self.critic_obs_dim
|
|
295
|
+
return obs[..., :a], obs[..., a:a + c]
|
|
296
|
+
|
|
297
|
+
def act(self, obs, eps):
|
|
298
|
+
"""actor_critic.py:1086-1129 without the log-probability (see deviation 8): a = mean + sigma eps, and the value."""
|
|
299
|
+
oa, oc = self._split(obs)
|
|
300
|
+
mean = self.actor_mean(oa)
|
|
301
|
+
std = self.physical_log_std().expand_as(mean).exp()
|
|
302
|
+
return torch.addcmul(mean, std, eps), self.value(oc)
|
|
303
|
+
|
|
304
|
+
def evaluate(self, obs, actions):
|
|
305
|
+
"""actor_critic.py:754-806 with distributions.py:19-59, 70-73: log-probability, value, entropy (each [B, 1]), mean, log std."""
|
|
306
|
+
oa, oc = self._split(obs)
|
|
307
|
+
mean = self.actor_mean(oa)
|
|
308
|
+
log_std = self.physical_log_std().expand_as(mean)
|
|
309
|
+
std = log_std.exp()
|
|
310
|
+
noise = (actions - mean) / std
|
|
311
|
+
log_prob = torch.sum(-0.5 * noise.square() - log_std - LOG_2PI_HALF, dim=-1, keepdim=True)
|
|
312
|
+
entropy = torch.sum(log_std + NORMAL_ENTROPY_CONST, dim=-1, keepdim=True)
|
|
313
|
+
return log_prob, self.value(oc), entropy, mean, log_std
|
|
314
|
+
|
|
315
|
+
def ppo_parameter_groups(self):
|
|
316
|
+
"""actor_critic.py:395-420: actor = sigma + actor_trunk.* + policy_head.*, critic = trunk.* + value_head.*, in
|
|
317
|
+
named_parameters order."""
|
|
318
|
+
actor, critic = [], []
|
|
319
|
+
for name, p in self.named_parameters():
|
|
320
|
+
if p is self.log_std or name.startswith(("actor_trunk.", "policy_head.")):
|
|
321
|
+
actor.append(p)
|
|
322
|
+
else:
|
|
323
|
+
assert name.startswith(("trunk.", "value_head.")), name
|
|
324
|
+
critic.append(p)
|
|
325
|
+
return actor, critic
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def make_bm_optimisers(model, cfg, lr_t):
|
|
329
|
+
"""Hybrid Muon + AdamW (S/rl/optimizers.py:228-307, 676-747) with one shared 0-dim float32 lr tensor (deviation 3); the state
|
|
330
|
+
materialised without a step as IM does before capture (agent.py:2709-2808)."""
|
|
331
|
+
named = list(model.named_parameters())
|
|
332
|
+
muon = [p for n, p in named if is_muon_hidden_layer_param(n, p)]
|
|
333
|
+
rest = [p for n, p in named if p.requires_grad and not is_muon_hidden_layer_param(n, p)]
|
|
334
|
+
assert len({tuple(p.shape) for p in muon}) == len(muon), "IM batches equal shapes (optimizers.py:544-577); our port does not"
|
|
335
|
+
mu = CapturableMuon(muon, lr=lr_t, **cfg["muon"])
|
|
336
|
+
cuda = lr_t.device.type == "cuda"
|
|
337
|
+
ad = torch.optim.AdamW(rest, lr=lr_t if cuda else float(lr_t), capturable=cuda, **cfg["adamw"])
|
|
338
|
+
with torch.no_grad():
|
|
339
|
+
for p in muon:
|
|
340
|
+
mu.state[p]["momentum_buffer"] = torch.zeros_like(p)
|
|
341
|
+
for p in rest:
|
|
342
|
+
st = ad.state[p]
|
|
343
|
+
st["step"] = torch.zeros((), dtype=torch.float32, device=p.device if cuda else "cpu")
|
|
344
|
+
st["exp_avg"] = torch.zeros_like(p)
|
|
345
|
+
st["exp_avg_sq"] = torch.zeros_like(p)
|
|
346
|
+
return mu, ad
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
def network_matmul_precision(device):
|
|
350
|
+
"""S/utils/network_precision.py:69-85: TF32 ("high") float32 matmuls while a network runs; CUDA only (deviation 6)."""
|
|
351
|
+
if device.type != "cuda":
|
|
352
|
+
return contextlib.nullcontext()
|
|
353
|
+
return _tf32_scope()
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
@contextlib.contextmanager
|
|
357
|
+
def _tf32_scope():
|
|
358
|
+
prev = torch.get_float32_matmul_precision()
|
|
359
|
+
torch.set_float32_matmul_precision("high")
|
|
360
|
+
yield
|
|
361
|
+
torch.set_float32_matmul_precision(prev)
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
# ----------------------------------------------------------------------------------------------------------- the agent
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
class BMPPO:
|
|
368
|
+
STAT_NAMES = ("kl", "lr", "policy_loss", "value_loss", "entropy_loss", "clip_fraction", "std", "reward", "term_rate",
|
|
369
|
+
"trunc_rate")
|
|
370
|
+
_M_POLICY, _M_VALUE, _M_ENTROPY, _M_KL, _M_CLIP = range(5)
|
|
371
|
+
|
|
372
|
+
def __init__(self, env, cfg=BM_CFG, seed=0):
|
|
373
|
+
self.env, self.cfg = env, dict(cfg)
|
|
374
|
+
cfg = self.cfg
|
|
375
|
+
self.dev, self.dt, n = torch.device(env.dev), env.dt, int(env.n)
|
|
376
|
+
self.na, self.nc, self.A = int(env.actor_obs_dim), int(env.critic_obs_dim), int(env.act_dim)
|
|
377
|
+
self.D = self.na + self.nc
|
|
378
|
+
R, E, M = cfg["rollouts"], cfg["epochs"], cfg["minibatches"]
|
|
379
|
+
self.N = R * n
|
|
380
|
+
assert self.N % M == 0, (self.N, M) # agent.py:67-80
|
|
381
|
+
self.mb = self.N // M
|
|
382
|
+
torch.manual_seed(seed)
|
|
383
|
+
self.model = BMActorCritic(self.na, self.nc, self.A, cfg).to(device=self.dev, dtype=self.dt)
|
|
384
|
+
self.lr_t = torch.tensor(float(cfg["lr"]), device=self.dev, dtype=torch.float32)
|
|
385
|
+
self.lr_c = lr_schedule_constants(cfg, self.dev)
|
|
386
|
+
self.muon, self.adamw = make_bm_optimisers(self.model, cfg, self.lr_t)
|
|
387
|
+
self.actor_params, self.critic_params = self.model.ppo_parameter_groups()
|
|
388
|
+
self.norm = EmpiricalNorm(self.D, self.dev, self.dt, cfg["norm_eps"])
|
|
389
|
+
z = lambda *s: torch.zeros(*s, device=self.dev, dtype=self.dt) # noqa: E731
|
|
390
|
+
self.buf = dict(obs=z(R, n, self.D), act=z(R, n, self.A), val=z(R, n, 1), rew=z(R, n, 1), done=z(R, n, 1),
|
|
391
|
+
tv=z(R, n, 1), term=z(R, n, 1), trunc=z(R, n, 1), adv=z(R, n, 1), ret=z(R, n, 1), last_v=z(n, 1))
|
|
392
|
+
self.ws = dict(obs=z(self.N, self.D), act=z(self.N, self.A), val=z(self.N, 1), ret=z(self.N, 1), adv=z(self.N, 1),
|
|
393
|
+
old_logp=z(self.N, 1), old_mean=z(self.N, self.A))
|
|
394
|
+
self.perm = torch.arange(self.N, device=self.dev, dtype=torch.int32)
|
|
395
|
+
self.metrics = torch.zeros(E * M, 5, device=self.dev, dtype=torch.float32)
|
|
396
|
+
self.stat_t = torch.zeros(len(self.STAT_NAMES), device=self.dev, dtype=torch.float32)
|
|
397
|
+
out = env.reset_all()
|
|
398
|
+
self.obs = torch.cat([out["actor"], out["critic"]], -1) # raw; it seeds buf.obs[0] (runtime.py:858-862)
|
|
399
|
+
assert self.obs.shape == (n, self.D) and self.obs.dtype == self.dt, (self.obs.shape, self.obs.dtype)
|
|
400
|
+
self.it = 0
|
|
401
|
+
self.stats = {}
|
|
402
|
+
self.S, self.graphs = None, None # set by capture()
|
|
403
|
+
|
|
404
|
+
# -------------------------------------------------------------------------------------------------- rollout
|
|
405
|
+
|
|
406
|
+
def _check(self, out):
|
|
407
|
+
n = self.env.n
|
|
408
|
+
for k, w in (("actor", self.na), ("critic", self.nc), ("terminal_actor", self.na), ("terminal_critic", self.nc)):
|
|
409
|
+
assert out[k].shape == (n, w) and out[k].dtype == self.dt, (k, out[k].shape, out[k].dtype)
|
|
410
|
+
assert out["reward"].shape == (n,) and out["reward"].dtype == self.dt, (out["reward"].shape, out["reward"].dtype)
|
|
411
|
+
for k in ("terminated", "truncated"):
|
|
412
|
+
assert out[k].shape == (n,) and out[k].dtype == torch.bool, (k, out[k].shape, out[k].dtype)
|
|
413
|
+
|
|
414
|
+
@torch.no_grad()
|
|
415
|
+
def rollout(self):
|
|
416
|
+
"""R env steps in IM's order (rollout.py:762-785), then the update's preamble that reads no learning state: the last value,
|
|
417
|
+
the rewards with the time-out bootstrap and GAE (agent.py:3363-3404, 250-313). IM runs that preamble at the start of its
|
|
418
|
+
update; nothing changes between the two points and it draws no random numbers, so ending the rollout with it is the same
|
|
419
|
+
arithmetic and lets the rollout graph end with the advantages (as g1_ppo's rollout graph does)."""
|
|
420
|
+
cfg, b, env = self.cfg, self.buf, self.env
|
|
421
|
+
for k in range(cfg["rollouts"]):
|
|
422
|
+
b["obs"][k].copy_(self.norm(self.obs)) # the policy-input snapshot
|
|
423
|
+
eps = torch.randn(env.n, self.A, device=self.dev, dtype=self.dt)
|
|
424
|
+
with network_matmul_precision(self.dev):
|
|
425
|
+
a, v = self.model.act(b["obs"][k], eps)
|
|
426
|
+
b["act"][k].copy_(a)
|
|
427
|
+
b["val"][k].copy_(v)
|
|
428
|
+
out = env.step(a)
|
|
429
|
+
self._check(out)
|
|
430
|
+
term, trunc = out["terminated"], out["truncated"]
|
|
431
|
+
b["rew"][k, :, 0].copy_(out["reward"])
|
|
432
|
+
b["done"][k, :, 0].copy_(term | trunc) # reset_buf = terminated | time-out
|
|
433
|
+
b["term"][k, :, 0].copy_(term)
|
|
434
|
+
b["trunc"][k, :, 0].copy_(trunc)
|
|
435
|
+
self.obs.copy_(torch.cat([out["actor"], out["critic"]], -1))
|
|
436
|
+
self.norm.update(self.obs) # rollout.py:778
|
|
437
|
+
with network_matmul_precision(self.dev): # rollout.py:862-920 after the update
|
|
438
|
+
tv = self.model.value(self.norm(out["terminal_critic"], slice(self.na, self.D)))
|
|
439
|
+
b["tv"][k].copy_(tv.masked_fill(~trunc.view(-1, 1), 0.0)) # agent.py:3340-3349
|
|
440
|
+
with network_matmul_precision(self.dev): # the last value: buf.obs[R] (agent.py:3392-3394)
|
|
441
|
+
b["last_v"].copy_(self.model.value(self.norm(self.obs[:, self.na:], slice(self.na, self.D))))
|
|
442
|
+
rewards = b["rew"].add(b["tv"], alpha=cfg["gamma"]) # agent.py:3363-3382
|
|
443
|
+
gae_(rewards, b["val"], b["done"], b["last_v"], b["adv"], b["ret"], cfg["gamma"], cfg["lam"], cfg["adv_eps"])
|
|
444
|
+
|
|
445
|
+
# -------------------------------------------------------------------------------------------------- update
|
|
446
|
+
|
|
447
|
+
def update(self):
|
|
448
|
+
cfg, b, ws, mb = self.cfg, self.buf, self.ws, self.mb
|
|
449
|
+
with network_matmul_precision(self.dev):
|
|
450
|
+
with torch.no_grad():
|
|
451
|
+
old_log_std = self.model.physical_log_std().detach().view(1, -1) # agent.py:3834-3845, 4647
|
|
452
|
+
# their randperm (agent.py:3581-3594, 4634) as argsort(rand): the same uniform permutation law, a different stream;
|
|
453
|
+
# argsort(rand) is the form arm A's capture gate passed bitwise (W2b C1), randperm under capture is unverified
|
|
454
|
+
self.perm.copy_(torch.argsort(torch.rand(self.N, device=self.dev)))
|
|
455
|
+
for key, src in (("obs", b["obs"]), ("act", b["act"]), ("val", b["val"]), ("ret", b["ret"]), ("adv", b["adv"])):
|
|
456
|
+
torch.index_select(src.reshape(self.N, -1), 0, self.perm, out=ws[key]) # agent.py:3652-3705
|
|
457
|
+
for j in range(cfg["minibatches"]): # agent.py:3108-3163
|
|
458
|
+
s = slice(j * mb, (j + 1) * mb)
|
|
459
|
+
logp, _, _, mean, _ = self.model.evaluate(ws["obs"][s], ws["act"][s])
|
|
460
|
+
ws["old_logp"][s].copy_(logp)
|
|
461
|
+
ws["old_mean"][s].copy_(mean)
|
|
462
|
+
for e in range(cfg["epochs"]):
|
|
463
|
+
for j in range(cfg["minibatches"]):
|
|
464
|
+
self._minibatch(slice(j * mb, (j + 1) * mb), old_log_std, self.metrics[e * cfg["minibatches"] + j])
|
|
465
|
+
with torch.no_grad():
|
|
466
|
+
m = self.metrics.mean(0)
|
|
467
|
+
std = self.model.physical_log_std().exp().mean()
|
|
468
|
+
self.stat_t.copy_(torch.stack([m[self._M_KL], self.lr_t, m[self._M_POLICY], m[self._M_VALUE], m[self._M_ENTROPY],
|
|
469
|
+
m[self._M_CLIP], std.float(), b["rew"].mean().float(), b["term"].mean().float(),
|
|
470
|
+
b["trunc"].mean().float()]))
|
|
471
|
+
|
|
472
|
+
def _minibatch(self, s, old_log_std, out_metrics):
|
|
473
|
+
"""agent.py:3165-3328."""
|
|
474
|
+
cfg, ws = self.cfg, self.ws
|
|
475
|
+
logp, value, entropy, mean, log_std = self.model.evaluate(ws["obs"][s], ws["act"][s])
|
|
476
|
+
with torch.no_grad():
|
|
477
|
+
kl = diagonal_gaussian_kl_mean(ws["old_mean"][s], old_log_std, mean.detach(), log_std.detach())
|
|
478
|
+
pol, val, ent, clip_frac = ppo_loss_terms(logp, ws["old_logp"][s], value, ws["val"][s], ws["ret"][s], ws["adv"][s], entropy,
|
|
479
|
+
cfg)
|
|
480
|
+
kl_adaptive_lr_(self.lr_t, kl, self.lr_c) # before this minibatch's step, on the device
|
|
481
|
+
self.muon.zero_grad(set_to_none=True)
|
|
482
|
+
self.adamw.zero_grad(set_to_none=True)
|
|
483
|
+
(pol + val + ent).backward()
|
|
484
|
+
clip_group_grad_norm_(self.actor_params, cfg["grad_clip"], self.dev)
|
|
485
|
+
clip_group_grad_norm_(self.critic_params, cfg["grad_clip"], self.dev)
|
|
486
|
+
self.muon.step()
|
|
487
|
+
self._adamw_step()
|
|
488
|
+
with torch.no_grad():
|
|
489
|
+
out_metrics.copy_(torch.stack([pol.detach().float(), val.detach().float(), ent.detach().float(), kl, clip_frac]))
|
|
490
|
+
|
|
491
|
+
def _adamw_step(self):
|
|
492
|
+
"""On CUDA AdamW is capturable and reads the device lr tensor. On the CPU (tests) torch refuses a capturable AdamW: it holds a
|
|
493
|
+
float lr, refreshed here from the lr tensor (deviation 5), and torch reads its step counter on the host."""
|
|
494
|
+
if self.dev.type != "cuda":
|
|
495
|
+
for g in self.adamw.param_groups:
|
|
496
|
+
g["lr"] = float(self.lr_t)
|
|
497
|
+
self.adamw.step()
|
|
498
|
+
|
|
499
|
+
# -------------------------------------------------------------------------------------------------- driver
|
|
500
|
+
|
|
501
|
+
def _sync(self):
|
|
502
|
+
if self.dev.type == "cuda":
|
|
503
|
+
torch.cuda.synchronize(self.dev)
|
|
504
|
+
|
|
505
|
+
def iteration(self):
|
|
506
|
+
"""One iteration (the captured one after capture()); phases timed on CLOCK_MONOTONIC_RAW after a device sync."""
|
|
507
|
+
if self.graphs is not None:
|
|
508
|
+
return self.iteration_captured()
|
|
509
|
+
self._sync(); t0 = raw_now()
|
|
510
|
+
self.rollout()
|
|
511
|
+
self._sync(); t1 = raw_now()
|
|
512
|
+
self.update()
|
|
513
|
+
self._sync(); t2 = raw_now()
|
|
514
|
+
self.it += 1
|
|
515
|
+
self.stats = dict(zip(self.STAT_NAMES, self.stat_t.tolist()), t_rollout=t1 - t0, t_update=t2 - t1)
|
|
516
|
+
return self.stats
|
|
517
|
+
|
|
518
|
+
@torch.no_grad()
|
|
519
|
+
def act_mean(self, actor_obs_raw):
|
|
520
|
+
"""The policy mean for scoring: the actor columns of the normaliser (no update), then the actor (agent.py:3551-3555)."""
|
|
521
|
+
assert actor_obs_raw.shape[-1] == self.na and actor_obs_raw.dtype == self.dt, (actor_obs_raw.shape, actor_obs_raw.dtype)
|
|
522
|
+
with network_matmul_precision(self.dev):
|
|
523
|
+
return self.model.actor_mean(self.norm(actor_obs_raw, slice(0, self.na)))
|
|
524
|
+
|
|
525
|
+
# -------------------------------------------------------------------------------------------------- the captured iteration
|
|
526
|
+
|
|
527
|
+
def _make_static(self):
|
|
528
|
+
"""The env's mutable state at static addresses through its make_static / bind_static API (g1_ppo's ENV_STATE pattern). The
|
|
529
|
+
agent's own state (model, optimiser state, normaliser, rollout buffers with the current observations and adv / ret,
|
|
530
|
+
workspace, permutation, lr, metrics, stats) is allocated once and only written in place, so it is static already."""
|
|
531
|
+
self.S = self.env.make_static()
|
|
532
|
+
self.env.bind_static(self.S)
|
|
533
|
+
|
|
534
|
+
def _rollout_body(self):
|
|
535
|
+
self.env.bind_static(self.S)
|
|
536
|
+
self.rollout()
|
|
537
|
+
self.env.copy_into(self.S)
|
|
538
|
+
|
|
539
|
+
def _update_body(self):
|
|
540
|
+
self.update()
|
|
541
|
+
|
|
542
|
+
def capture(self, warmup=2):
|
|
543
|
+
"""Capture the rollout (+ GAE) and the update as two CUDA graphs, the second in the first's pool (as g1_ppo.PPO.capture).
|
|
544
|
+
Needs one eager iteration first. The warm-up iterations run on a side stream and mutate the state, so everything is
|
|
545
|
+
snapshot before them and restored in place after: the first replay is exactly the next iteration."""
|
|
546
|
+
assert self.dev.type == "cuda" and self.it >= 1 and self.graphs is None
|
|
547
|
+
self._make_static()
|
|
548
|
+
snap = self.snapshot()
|
|
549
|
+
side = torch.cuda.Stream(self.dev)
|
|
550
|
+
side.wait_stream(torch.cuda.current_stream(self.dev))
|
|
551
|
+
with torch.cuda.stream(side):
|
|
552
|
+
for _ in range(warmup):
|
|
553
|
+
self._rollout_body()
|
|
554
|
+
self._update_body()
|
|
555
|
+
torch.cuda.current_stream(self.dev).wait_stream(side)
|
|
556
|
+
torch.cuda.synchronize(self.dev)
|
|
557
|
+
self.restore(snap)
|
|
558
|
+
self.muon.zero_grad(set_to_none=True)
|
|
559
|
+
self.adamw.zero_grad(set_to_none=True)
|
|
560
|
+
torch.cuda.synchronize(self.dev)
|
|
561
|
+
g_roll, g_upd = torch.cuda.CUDAGraph(), torch.cuda.CUDAGraph()
|
|
562
|
+
with torch.cuda.graph(g_roll):
|
|
563
|
+
self._rollout_body()
|
|
564
|
+
with torch.cuda.graph(g_upd, pool=g_roll.pool()):
|
|
565
|
+
self._update_body()
|
|
566
|
+
self.env.bind_static(self.S) # eager reads see the static tensors
|
|
567
|
+
self.graphs = (g_roll, g_upd)
|
|
568
|
+
|
|
569
|
+
def iteration_captured(self):
|
|
570
|
+
"""The two replays, each timed after a device sync (outside the graphs); the stats read from the static vector after."""
|
|
571
|
+
g_roll, g_upd = self.graphs
|
|
572
|
+
self._sync(); t0 = raw_now()
|
|
573
|
+
g_roll.replay()
|
|
574
|
+
self._sync(); t1 = raw_now()
|
|
575
|
+
g_upd.replay()
|
|
576
|
+
self._sync(); t2 = raw_now()
|
|
577
|
+
self.it += 1
|
|
578
|
+
self.stats = dict(zip(self.STAT_NAMES, self.stat_t.tolist()), t_rollout=t1 - t0, t_update=t2 - t1)
|
|
579
|
+
return self.stats
|
|
580
|
+
|
|
581
|
+
# -------------------------------------------------------------------------------------------------- snapshots
|
|
582
|
+
|
|
583
|
+
def _tensors(self):
|
|
584
|
+
"""Every tensor an iteration reads or writes, by name (restored in place, so the captured addresses hold)."""
|
|
585
|
+
d = {f"model.{k}": v for k, v in self.model.state_dict(keep_vars=True).items()}
|
|
586
|
+
for oname, o in (("muon", self.muon), ("adamw", self.adamw)):
|
|
587
|
+
for gi, g in enumerate(o.param_groups):
|
|
588
|
+
for pi, p in enumerate(g["params"]):
|
|
589
|
+
for k, v in o.state[p].items():
|
|
590
|
+
assert torch.is_tensor(v), (oname, k)
|
|
591
|
+
d[f"{oname}.{gi}.{pi}.{k}"] = v
|
|
592
|
+
d.update({f"norm.{k}": v for k, v in self.norm.state_dict(keep_vars=True).items()})
|
|
593
|
+
d.update({f"buf.{k}": v for k, v in self.buf.items()})
|
|
594
|
+
d.update({f"ws.{k}": v for k, v in self.ws.items()})
|
|
595
|
+
d.update(lr_t=self.lr_t, perm=self.perm, metrics=self.metrics, stat_t=self.stat_t, obs=self.obs)
|
|
596
|
+
return d
|
|
597
|
+
|
|
598
|
+
def snapshot(self):
|
|
599
|
+
snap = {k: v.detach().clone() for k, v in self._tensors().items()}
|
|
600
|
+
snap["env"] = self.env.snapshot()
|
|
601
|
+
snap["rng_cpu"] = torch.get_rng_state()
|
|
602
|
+
if self.dev.type == "cuda":
|
|
603
|
+
snap["rng_cuda"] = torch.cuda.get_rng_state(self.dev)
|
|
604
|
+
snap["it"] = self.it
|
|
605
|
+
return snap
|
|
606
|
+
|
|
607
|
+
@torch.no_grad()
|
|
608
|
+
def restore(self, snap):
|
|
609
|
+
"""In place: the agent's tensors by copy; the env by its restore, then, once static state exists, copied into the static
|
|
610
|
+
tensors and rebound (as g1_ppo.restore with S), so the captured graphs keep reading the same addresses."""
|
|
611
|
+
cur = self._tensors()
|
|
612
|
+
assert cur.keys() == {k for k in snap if k not in ("env", "rng_cpu", "rng_cuda", "it")}, "state keys changed"
|
|
613
|
+
for k, v in cur.items():
|
|
614
|
+
v.data.copy_(snap[k])
|
|
615
|
+
self.env.restore(snap["env"])
|
|
616
|
+
if self.S is not None:
|
|
617
|
+
self.env.copy_into(self.S)
|
|
618
|
+
self.env.bind_static(self.S)
|
|
619
|
+
torch.set_rng_state(snap["rng_cpu"])
|
|
620
|
+
if self.dev.type == "cuda":
|
|
621
|
+
torch.cuda.set_rng_state(snap["rng_cuda"], self.dev)
|
|
622
|
+
self.it = snap["it"]
|