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.
Files changed (682) hide show
  1. diffneusim/__init__.py +1 -0
  2. diffneusim/_cache.py +42 -0
  3. diffneusim/_paths.py +5 -0
  4. diffneusim/bindings/rew14_ext.cu +115 -0
  5. diffneusim/bindings/soft14_capi.cpp +443 -0
  6. diffneusim/bindings/soft14_engine_ext.cu +596 -0
  7. diffneusim/bindings/soft_capi.cpp +782 -0
  8. diffneusim/bindings/soft_engine_ext.cu +495 -0
  9. diffneusim/core/cpu_engine/build.sh +40 -0
  10. diffneusim/core/cpu_engine/fiber/cuda_runtime.h +445 -0
  11. diffneusim/core/cpu_engine/x14_cpu.cpp +283 -0
  12. diffneusim/core/diff/dual.h +126 -0
  13. diffneusim/core/include/diffneusim/macros.h +35 -0
  14. diffneusim/core/kin/kinematic_tree.h +273 -0
  15. diffneusim/core/math/so3.h +182 -0
  16. diffneusim/core/soft/adj/out_adj.h +102 -0
  17. diffneusim/core/soft/adj/rnea_adj.h +425 -0
  18. diffneusim/core/soft/adj/rows_adj.h +439 -0
  19. diffneusim/core/soft/adj/rows_functor.h +89 -0
  20. diffneusim/core/soft/adj/rows_lanes.h +443 -0
  21. diffneusim/core/soft/adj/shell_adj.h +243 -0
  22. diffneusim/core/soft/adj/tree_adj.h +356 -0
  23. diffneusim/core/soft/collide.h +183 -0
  24. diffneusim/core/soft/gpu/adj14.cuh +233 -0
  25. diffneusim/core/soft/gpu/adj14_mus.cuh +98 -0
  26. diffneusim/core/soft/gpu/adj_shell.cuh +50 -0
  27. diffneusim/core/soft/gpu/adj_tab.cuh +49 -0
  28. diffneusim/core/soft/gpu/body14.cuh +47 -0
  29. diffneusim/core/soft/gpu/chol_rn.cuh +458 -0
  30. diffneusim/core/soft/gpu/chol_small.cuh +123 -0
  31. diffneusim/core/soft/gpu/chol_split.cuh +193 -0
  32. diffneusim/core/soft/gpu/engine_launch.cuh +263 -0
  33. diffneusim/core/soft/gpu/fk_rn.cuh +109 -0
  34. diffneusim/core/soft/gpu/generated/body_019e20820f86_mmfloor.cuh +28 -0
  35. diffneusim/core/soft/gpu/generated/body_62f77a4bb16b_mmfloor.cuh +52 -0
  36. diffneusim/core/soft/gpu/generated/body_77dbb7213f26_mmfloor_rampsb3l_n6t12.cuh +28 -0
  37. diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rampsb3l_n6t12.cuh +28 -0
  38. diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rhlsd05_n6t12.cuh +28 -0
  39. diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rhlsdef_n6t12.cuh +28 -0
  40. diffneusim/core/soft/gpu/generated/body_8989b60e4486_mmfloor_rhlsmjd_n6t12.cuh +28 -0
  41. diffneusim/core/soft/gpu/generated/body_a1e8b196b2cd_mmfloor_rampsb3l_n6t12.cuh +52 -0
  42. diffneusim/core/soft/gpu/generated/body_a944653edd64_mmfloor.cuh +25 -0
  43. diffneusim/core/soft/gpu/generated/body_a944653edd64_mmfloor_rampsb3l_n6t12.cuh +25 -0
  44. diffneusim/core/soft/gpu/generated/g1_soft_5db44fd45286.cuh +74 -0
  45. diffneusim/core/soft/gpu/generated/split_62f77a4bb16b_mmfloor.cuh +18 -0
  46. diffneusim/core/soft/gpu/generated/split_a1e8b196b2cd_mmfloor_rampsb3l_n6t12.cuh +18 -0
  47. diffneusim/core/soft/gpu/generated/x14_soft_019e20820f86_mmfloor.cuh +123 -0
  48. diffneusim/core/soft/gpu/generated/x14_soft_62f77a4bb16b_mmfloor.cuh +129 -0
  49. diffneusim/core/soft/gpu/generated/x14_soft_77dbb7213f26_mmfloor_rampsb3l_n6t12.cuh +123 -0
  50. diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rampsb3l_n6t12.cuh +123 -0
  51. diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rhlsd05_n6t12.cuh +123 -0
  52. diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rhlsdef_n6t12.cuh +123 -0
  53. diffneusim/core/soft/gpu/generated/x14_soft_8989b60e4486_mmfloor_rhlsmjd_n6t12.cuh +123 -0
  54. diffneusim/core/soft/gpu/generated/x14_soft_a1e8b196b2cd_mmfloor_rampsb3l_n6t12.cuh +129 -0
  55. diffneusim/core/soft/gpu/generated/x14_soft_a944653edd64_mmfloor.cuh +123 -0
  56. diffneusim/core/soft/gpu/generated/x14_soft_a944653edd64_mmfloor_rampsb3l_n6t12.cuh +123 -0
  57. diffneusim/core/soft/gpu/k_mus.cuh +1038 -0
  58. diffneusim/core/soft/gpu/k_mus_host.cuh +377 -0
  59. diffneusim/core/soft/gpu/k_pre.cuh +52 -0
  60. diffneusim/core/soft/gpu/kernel_p.cuh +490 -0
  61. diffneusim/core/soft/gpu/kp14.cuh +465 -0
  62. diffneusim/core/soft/gpu/l2v2.cuh +367 -0
  63. diffneusim/core/soft/gpu/l2x14.cuh +319 -0
  64. diffneusim/core/soft/gpu/l3.cuh +1483 -0
  65. diffneusim/core/soft/gpu/model_view.cuh +48 -0
  66. diffneusim/core/soft/gpu/mus_case_fits.h +15 -0
  67. diffneusim/core/soft/gpu/mus_classes.h +182 -0
  68. diffneusim/core/soft/gpu/mus_row_cf.h +44 -0
  69. diffneusim/core/soft/gpu/rew14.cuh +177 -0
  70. diffneusim/core/soft/gpu/rows_ctab.cuh +44 -0
  71. diffneusim/core/soft/gpu/tree_m.cuh +247 -0
  72. diffneusim/core/soft/gpu/x14_engine_kernels.cuh +260 -0
  73. diffneusim/core/soft/gpu/x14_rowcf.h +14 -0
  74. diffneusim/core/soft/hand.h +124 -0
  75. diffneusim/core/soft/impedance.h +115 -0
  76. diffneusim/core/soft/jvp.h +202 -0
  77. diffneusim/core/soft/kin.h +250 -0
  78. diffneusim/core/soft/muscle.h +1208 -0
  79. diffneusim/core/soft/newton.h +371 -0
  80. diffneusim/core/soft/rows.h +176 -0
  81. diffneusim/core/soft/step.h +188 -0
  82. diffneusim/core/soft/tape.h +313 -0
  83. diffneusim/core/soft/x14/collide14.h +69 -0
  84. diffneusim/core/soft/x14/jvp14.h +182 -0
  85. diffneusim/core/soft/x14/law14.h +453 -0
  86. diffneusim/core/soft/x14adj/collide14_adj.h +134 -0
  87. diffneusim/core/soft/x14adj/passive14_adj.h +162 -0
  88. diffneusim/core/soft/x14adj/reward14.h +484 -0
  89. diffneusim/core/soft/x14adj/rows14_adj.h +400 -0
  90. diffneusim/core/soft/x14adj/scan14.h +349 -0
  91. diffneusim/core/soft/x14adj/shell14_adj.h +122 -0
  92. diffneusim/core/soft/x14adj/sweep14.h +255 -0
  93. diffneusim/core/soft/x14adj/tree14_adj.h +500 -0
  94. diffneusim/core/soft/x14adj/x14adj_common.h +96 -0
  95. diffneusim/data/mirror/H1622v2k_geyer_hfdeq.npz +0 -0
  96. diffneusim/data/mirror/H1622v2k_hfd.npz +0 -0
  97. diffneusim/data/mirror/H1622v2k_millard_hfdeq.npz +0 -0
  98. diffneusim/data/mirror/fullbody_contact.npz +0 -0
  99. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard.npz +0 -0
  100. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_p2str.npz +0 -0
  101. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_p2str_rigid.npz +0 -0
  102. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.npz +0 -0
  103. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid.npz +0 -0
  104. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq.npz +0 -0
  105. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin.npz +0 -0
  106. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_calf2_pe.npz +0 -0
  107. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc.npz +0 -0
  108. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_axfix.npz +0 -0
  109. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_axfixlegs01.npz +0 -0
  110. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_jd01.npz +0 -0
  111. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_jd01legs.npz +0 -0
  112. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_jd01lumbar.npz +0 -0
  113. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_lumbfix.npz +0 -0
  114. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_lumbfixlegs01.npz +0 -0
  115. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.npz +0 -0
  116. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1a.npz +0 -0
  117. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n2.npz +0 -0
  118. diffneusim/data/mirror/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_rom23.npz +0 -0
  119. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair.npz +0 -0
  120. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc.npz +0 -0
  121. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_hinge.npz +0 -0
  122. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.npz +0 -0
  123. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1a.npz +0 -0
  124. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n2.npz +0 -0
  125. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_rom23.npz +0 -0
  126. diffneusim/data/mirror/fullbody_contact_spinecoupled_fusedhand_lspine_girdle_osimeq.npz +0 -0
  127. diffneusim/data/mirror/fullbody_contact_spinecoupled_lspine_girdle_millard.npz +0 -0
  128. diffneusim/data/mirror/fullbody_contact_spinecoupled_lspine_girdle_osimeq.npz +0 -0
  129. diffneusim/data/mirror/myoleg26_3d_compound_g14eq.npz +0 -0
  130. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq.npz +0 -0
  131. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose.npz +0 -0
  132. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin.npz +0 -0
  133. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30.npz +0 -0
  134. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30_hip30.npz +0 -0
  135. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30_hip30_luispe.npz +0 -0
  136. diffneusim/data/mirror/myoleg26_3d_kneeexp_g14eq_trunkpose_spin_ank30_hip30_trunk0701.npz +0 -0
  137. diffneusim/data/muscle_fit/wang_mass_volume_14t.json +91 -0
  138. diffneusim/data/muscle_fit/wang_mass_volume_14t_axfix.json +91 -0
  139. diffneusim/data/muscle_fit/wang_mass_volume_14t_axfixlegs01.json +91 -0
  140. diffneusim/data/muscle_fit/wang_mass_volume_14t_jd01.json +91 -0
  141. diffneusim/data/muscle_fit/wang_mass_volume_14t_jd01legs.json +91 -0
  142. diffneusim/data/muscle_fit/wang_mass_volume_14t_jd01lumbar.json +91 -0
  143. diffneusim/data/muscle_fit/wang_mass_volume_14t_lumbfix.json +91 -0
  144. diffneusim/data/muscle_fit/wang_mass_volume_14t_lumbfixlegs01.json +91 -0
  145. diffneusim/data/muscle_fit/wang_mass_volume_14t_n1.json +91 -0
  146. diffneusim/data/muscle_fit/wang_mass_volume_14t_n1a.json +91 -0
  147. diffneusim/data/muscle_fit/wang_mass_volume_14t_n2.json +91 -0
  148. diffneusim/data/muscle_fit/wang_mass_volume_14t_rom23.json +91 -0
  149. diffneusim/data/reference/musclemimic/myofullbody_mimic_sites.json +261 -0
  150. diffneusim/data/reference/pose3/pose3_scone.json +305 -0
  151. diffneusim/data/reference/pose3/pose3_scone.txt +3 -0
  152. diffneusim/data/reference/pose3/pose3_scone_gait.npz +0 -0
  153. diffneusim/data/reference/pose3/pose3_scone_mirror.npz +0 -0
  154. diffneusim/data/reference/pose3/pose3_scone_stand.npz +0 -0
  155. diffneusim/data/reference/x016run/MD5SUMS +241 -0
  156. diffneusim/data/reference/x016run/x016run_states.txt +240 -0
  157. diffneusim/data/reference/x016run/x016run_v3p00_s0_l0.npz +0 -0
  158. diffneusim/data/reference/x016run/x016run_v3p00_s0_l1.npz +0 -0
  159. diffneusim/data/reference/x016run/x016run_v3p00_s0_l2.npz +0 -0
  160. diffneusim/data/reference/x016run/x016run_v3p00_s0_l3.npz +0 -0
  161. diffneusim/data/reference/x016run/x016run_v3p00_s0_r0.npz +0 -0
  162. diffneusim/data/reference/x016run/x016run_v3p00_s0_r1.npz +0 -0
  163. diffneusim/data/reference/x016run/x016run_v3p00_s0_r2.npz +0 -0
  164. diffneusim/data/reference/x016run/x016run_v3p00_s0_r3.npz +0 -0
  165. diffneusim/data/reference/x016run/x016run_v3p00_s1_l0.npz +0 -0
  166. diffneusim/data/reference/x016run/x016run_v3p00_s1_l1.npz +0 -0
  167. diffneusim/data/reference/x016run/x016run_v3p00_s1_l2.npz +0 -0
  168. diffneusim/data/reference/x016run/x016run_v3p00_s1_l3.npz +0 -0
  169. diffneusim/data/reference/x016run/x016run_v3p00_s1_r0.npz +0 -0
  170. diffneusim/data/reference/x016run/x016run_v3p00_s1_r1.npz +0 -0
  171. diffneusim/data/reference/x016run/x016run_v3p00_s1_r2.npz +0 -0
  172. diffneusim/data/reference/x016run/x016run_v3p00_s1_r3.npz +0 -0
  173. diffneusim/data/reference/x016run/x016run_v3p00_s2_l0.npz +0 -0
  174. diffneusim/data/reference/x016run/x016run_v3p00_s2_l1.npz +0 -0
  175. diffneusim/data/reference/x016run/x016run_v3p00_s2_l2.npz +0 -0
  176. diffneusim/data/reference/x016run/x016run_v3p00_s2_l3.npz +0 -0
  177. diffneusim/data/reference/x016run/x016run_v3p00_s2_r0.npz +0 -0
  178. diffneusim/data/reference/x016run/x016run_v3p00_s2_r1.npz +0 -0
  179. diffneusim/data/reference/x016run/x016run_v3p00_s2_r2.npz +0 -0
  180. diffneusim/data/reference/x016run/x016run_v3p00_s2_r3.npz +0 -0
  181. diffneusim/data/reference/x016run/x016run_v3p00_s3_l0.npz +0 -0
  182. diffneusim/data/reference/x016run/x016run_v3p00_s3_l1.npz +0 -0
  183. diffneusim/data/reference/x016run/x016run_v3p00_s3_l2.npz +0 -0
  184. diffneusim/data/reference/x016run/x016run_v3p00_s3_l3.npz +0 -0
  185. diffneusim/data/reference/x016run/x016run_v3p00_s3_r0.npz +0 -0
  186. diffneusim/data/reference/x016run/x016run_v3p00_s3_r1.npz +0 -0
  187. diffneusim/data/reference/x016run/x016run_v3p00_s3_r2.npz +0 -0
  188. diffneusim/data/reference/x016run/x016run_v3p00_s3_r3.npz +0 -0
  189. diffneusim/data/reference/x016run/x016run_v3p00_s4_l0.npz +0 -0
  190. diffneusim/data/reference/x016run/x016run_v3p00_s4_l1.npz +0 -0
  191. diffneusim/data/reference/x016run/x016run_v3p00_s4_l2.npz +0 -0
  192. diffneusim/data/reference/x016run/x016run_v3p00_s4_l3.npz +0 -0
  193. diffneusim/data/reference/x016run/x016run_v3p00_s4_r0.npz +0 -0
  194. diffneusim/data/reference/x016run/x016run_v3p00_s4_r1.npz +0 -0
  195. diffneusim/data/reference/x016run/x016run_v3p00_s4_r2.npz +0 -0
  196. diffneusim/data/reference/x016run/x016run_v3p00_s4_r3.npz +0 -0
  197. diffneusim/data/reference/x016run/x016run_v3p00_s5_l0.npz +0 -0
  198. diffneusim/data/reference/x016run/x016run_v3p00_s5_l1.npz +0 -0
  199. diffneusim/data/reference/x016run/x016run_v3p00_s5_l2.npz +0 -0
  200. diffneusim/data/reference/x016run/x016run_v3p00_s5_l3.npz +0 -0
  201. diffneusim/data/reference/x016run/x016run_v3p00_s5_r0.npz +0 -0
  202. diffneusim/data/reference/x016run/x016run_v3p00_s5_r1.npz +0 -0
  203. diffneusim/data/reference/x016run/x016run_v3p00_s5_r2.npz +0 -0
  204. diffneusim/data/reference/x016run/x016run_v3p00_s5_r3.npz +0 -0
  205. diffneusim/data/reference/x016run/x016run_v3p00_s6_l0.npz +0 -0
  206. diffneusim/data/reference/x016run/x016run_v3p00_s6_l1.npz +0 -0
  207. diffneusim/data/reference/x016run/x016run_v3p00_s6_l2.npz +0 -0
  208. diffneusim/data/reference/x016run/x016run_v3p00_s6_l3.npz +0 -0
  209. diffneusim/data/reference/x016run/x016run_v3p00_s6_r0.npz +0 -0
  210. diffneusim/data/reference/x016run/x016run_v3p00_s6_r1.npz +0 -0
  211. diffneusim/data/reference/x016run/x016run_v3p00_s6_r2.npz +0 -0
  212. diffneusim/data/reference/x016run/x016run_v3p00_s6_r3.npz +0 -0
  213. diffneusim/data/reference/x016run/x016run_v3p00_s7_l0.npz +0 -0
  214. diffneusim/data/reference/x016run/x016run_v3p00_s7_l1.npz +0 -0
  215. diffneusim/data/reference/x016run/x016run_v3p00_s7_l2.npz +0 -0
  216. diffneusim/data/reference/x016run/x016run_v3p00_s7_l3.npz +0 -0
  217. diffneusim/data/reference/x016run/x016run_v3p00_s7_r0.npz +0 -0
  218. diffneusim/data/reference/x016run/x016run_v3p00_s7_r1.npz +0 -0
  219. diffneusim/data/reference/x016run/x016run_v3p00_s7_r2.npz +0 -0
  220. diffneusim/data/reference/x016run/x016run_v3p00_s7_r3.npz +0 -0
  221. diffneusim/data/reference/x016run/x016run_v3p25_s0_l0.npz +0 -0
  222. diffneusim/data/reference/x016run/x016run_v3p25_s0_l1.npz +0 -0
  223. diffneusim/data/reference/x016run/x016run_v3p25_s0_l2.npz +0 -0
  224. diffneusim/data/reference/x016run/x016run_v3p25_s0_l3.npz +0 -0
  225. diffneusim/data/reference/x016run/x016run_v3p25_s0_r0.npz +0 -0
  226. diffneusim/data/reference/x016run/x016run_v3p25_s0_r1.npz +0 -0
  227. diffneusim/data/reference/x016run/x016run_v3p25_s0_r2.npz +0 -0
  228. diffneusim/data/reference/x016run/x016run_v3p25_s0_r3.npz +0 -0
  229. diffneusim/data/reference/x016run/x016run_v3p25_s1_l0.npz +0 -0
  230. diffneusim/data/reference/x016run/x016run_v3p25_s1_l1.npz +0 -0
  231. diffneusim/data/reference/x016run/x016run_v3p25_s1_l2.npz +0 -0
  232. diffneusim/data/reference/x016run/x016run_v3p25_s1_l3.npz +0 -0
  233. diffneusim/data/reference/x016run/x016run_v3p25_s1_r0.npz +0 -0
  234. diffneusim/data/reference/x016run/x016run_v3p25_s1_r1.npz +0 -0
  235. diffneusim/data/reference/x016run/x016run_v3p25_s1_r2.npz +0 -0
  236. diffneusim/data/reference/x016run/x016run_v3p25_s1_r3.npz +0 -0
  237. diffneusim/data/reference/x016run/x016run_v3p25_s2_l0.npz +0 -0
  238. diffneusim/data/reference/x016run/x016run_v3p25_s2_l1.npz +0 -0
  239. diffneusim/data/reference/x016run/x016run_v3p25_s2_l2.npz +0 -0
  240. diffneusim/data/reference/x016run/x016run_v3p25_s2_l3.npz +0 -0
  241. diffneusim/data/reference/x016run/x016run_v3p25_s2_r0.npz +0 -0
  242. diffneusim/data/reference/x016run/x016run_v3p25_s2_r1.npz +0 -0
  243. diffneusim/data/reference/x016run/x016run_v3p25_s2_r2.npz +0 -0
  244. diffneusim/data/reference/x016run/x016run_v3p25_s2_r3.npz +0 -0
  245. diffneusim/data/reference/x016run/x016run_v3p25_s3_l0.npz +0 -0
  246. diffneusim/data/reference/x016run/x016run_v3p25_s3_l1.npz +0 -0
  247. diffneusim/data/reference/x016run/x016run_v3p25_s3_l2.npz +0 -0
  248. diffneusim/data/reference/x016run/x016run_v3p25_s3_l3.npz +0 -0
  249. diffneusim/data/reference/x016run/x016run_v3p25_s3_r0.npz +0 -0
  250. diffneusim/data/reference/x016run/x016run_v3p25_s3_r1.npz +0 -0
  251. diffneusim/data/reference/x016run/x016run_v3p25_s3_r2.npz +0 -0
  252. diffneusim/data/reference/x016run/x016run_v3p25_s3_r3.npz +0 -0
  253. diffneusim/data/reference/x016run/x016run_v3p25_s4_l0.npz +0 -0
  254. diffneusim/data/reference/x016run/x016run_v3p25_s4_l1.npz +0 -0
  255. diffneusim/data/reference/x016run/x016run_v3p25_s4_l2.npz +0 -0
  256. diffneusim/data/reference/x016run/x016run_v3p25_s4_l3.npz +0 -0
  257. diffneusim/data/reference/x016run/x016run_v3p25_s4_r0.npz +0 -0
  258. diffneusim/data/reference/x016run/x016run_v3p25_s4_r1.npz +0 -0
  259. diffneusim/data/reference/x016run/x016run_v3p25_s4_r2.npz +0 -0
  260. diffneusim/data/reference/x016run/x016run_v3p25_s4_r3.npz +0 -0
  261. diffneusim/data/reference/x016run/x016run_v3p25_s5_l0.npz +0 -0
  262. diffneusim/data/reference/x016run/x016run_v3p25_s5_l1.npz +0 -0
  263. diffneusim/data/reference/x016run/x016run_v3p25_s5_l2.npz +0 -0
  264. diffneusim/data/reference/x016run/x016run_v3p25_s5_l3.npz +0 -0
  265. diffneusim/data/reference/x016run/x016run_v3p25_s5_r0.npz +0 -0
  266. diffneusim/data/reference/x016run/x016run_v3p25_s5_r1.npz +0 -0
  267. diffneusim/data/reference/x016run/x016run_v3p25_s5_r2.npz +0 -0
  268. diffneusim/data/reference/x016run/x016run_v3p25_s5_r3.npz +0 -0
  269. diffneusim/data/reference/x016run/x016run_v3p25_s6_l0.npz +0 -0
  270. diffneusim/data/reference/x016run/x016run_v3p25_s6_l1.npz +0 -0
  271. diffneusim/data/reference/x016run/x016run_v3p25_s6_l2.npz +0 -0
  272. diffneusim/data/reference/x016run/x016run_v3p25_s6_l3.npz +0 -0
  273. diffneusim/data/reference/x016run/x016run_v3p25_s6_r0.npz +0 -0
  274. diffneusim/data/reference/x016run/x016run_v3p25_s6_r1.npz +0 -0
  275. diffneusim/data/reference/x016run/x016run_v3p25_s6_r2.npz +0 -0
  276. diffneusim/data/reference/x016run/x016run_v3p25_s6_r3.npz +0 -0
  277. diffneusim/data/reference/x016run/x016run_v3p25_s7_l0.npz +0 -0
  278. diffneusim/data/reference/x016run/x016run_v3p25_s7_l1.npz +0 -0
  279. diffneusim/data/reference/x016run/x016run_v3p25_s7_l2.npz +0 -0
  280. diffneusim/data/reference/x016run/x016run_v3p25_s7_l3.npz +0 -0
  281. diffneusim/data/reference/x016run/x016run_v3p25_s7_r0.npz +0 -0
  282. diffneusim/data/reference/x016run/x016run_v3p25_s7_r1.npz +0 -0
  283. diffneusim/data/reference/x016run/x016run_v3p25_s7_r2.npz +0 -0
  284. diffneusim/data/reference/x016run/x016run_v3p25_s7_r3.npz +0 -0
  285. diffneusim/data/reference/x016run/x016run_v3p50_s0_l0.npz +0 -0
  286. diffneusim/data/reference/x016run/x016run_v3p50_s0_l1.npz +0 -0
  287. diffneusim/data/reference/x016run/x016run_v3p50_s0_l2.npz +0 -0
  288. diffneusim/data/reference/x016run/x016run_v3p50_s0_l3.npz +0 -0
  289. diffneusim/data/reference/x016run/x016run_v3p50_s0_r0.npz +0 -0
  290. diffneusim/data/reference/x016run/x016run_v3p50_s0_r1.npz +0 -0
  291. diffneusim/data/reference/x016run/x016run_v3p50_s0_r2.npz +0 -0
  292. diffneusim/data/reference/x016run/x016run_v3p50_s0_r3.npz +0 -0
  293. diffneusim/data/reference/x016run/x016run_v3p50_s1_l0.npz +0 -0
  294. diffneusim/data/reference/x016run/x016run_v3p50_s1_l1.npz +0 -0
  295. diffneusim/data/reference/x016run/x016run_v3p50_s1_l2.npz +0 -0
  296. diffneusim/data/reference/x016run/x016run_v3p50_s1_l3.npz +0 -0
  297. diffneusim/data/reference/x016run/x016run_v3p50_s1_r0.npz +0 -0
  298. diffneusim/data/reference/x016run/x016run_v3p50_s1_r1.npz +0 -0
  299. diffneusim/data/reference/x016run/x016run_v3p50_s1_r2.npz +0 -0
  300. diffneusim/data/reference/x016run/x016run_v3p50_s1_r3.npz +0 -0
  301. diffneusim/data/reference/x016run/x016run_v3p50_s2_l0.npz +0 -0
  302. diffneusim/data/reference/x016run/x016run_v3p50_s2_l1.npz +0 -0
  303. diffneusim/data/reference/x016run/x016run_v3p50_s2_l2.npz +0 -0
  304. diffneusim/data/reference/x016run/x016run_v3p50_s2_l3.npz +0 -0
  305. diffneusim/data/reference/x016run/x016run_v3p50_s2_r0.npz +0 -0
  306. diffneusim/data/reference/x016run/x016run_v3p50_s2_r1.npz +0 -0
  307. diffneusim/data/reference/x016run/x016run_v3p50_s2_r2.npz +0 -0
  308. diffneusim/data/reference/x016run/x016run_v3p50_s2_r3.npz +0 -0
  309. diffneusim/data/reference/x016run/x016run_v3p50_s3_l0.npz +0 -0
  310. diffneusim/data/reference/x016run/x016run_v3p50_s3_l1.npz +0 -0
  311. diffneusim/data/reference/x016run/x016run_v3p50_s3_l2.npz +0 -0
  312. diffneusim/data/reference/x016run/x016run_v3p50_s3_l3.npz +0 -0
  313. diffneusim/data/reference/x016run/x016run_v3p50_s3_r0.npz +0 -0
  314. diffneusim/data/reference/x016run/x016run_v3p50_s3_r1.npz +0 -0
  315. diffneusim/data/reference/x016run/x016run_v3p50_s3_r2.npz +0 -0
  316. diffneusim/data/reference/x016run/x016run_v3p50_s3_r3.npz +0 -0
  317. diffneusim/data/reference/x016run/x016run_v3p50_s5_l0.npz +0 -0
  318. diffneusim/data/reference/x016run/x016run_v3p50_s5_l1.npz +0 -0
  319. diffneusim/data/reference/x016run/x016run_v3p50_s5_l2.npz +0 -0
  320. diffneusim/data/reference/x016run/x016run_v3p50_s5_l3.npz +0 -0
  321. diffneusim/data/reference/x016run/x016run_v3p50_s5_r0.npz +0 -0
  322. diffneusim/data/reference/x016run/x016run_v3p50_s5_r1.npz +0 -0
  323. diffneusim/data/reference/x016run/x016run_v3p50_s5_r2.npz +0 -0
  324. diffneusim/data/reference/x016run/x016run_v3p50_s5_r3.npz +0 -0
  325. diffneusim/data/reference/x016run/x016run_v3p50_s6_l0.npz +0 -0
  326. diffneusim/data/reference/x016run/x016run_v3p50_s6_l1.npz +0 -0
  327. diffneusim/data/reference/x016run/x016run_v3p50_s6_l2.npz +0 -0
  328. diffneusim/data/reference/x016run/x016run_v3p50_s6_l3.npz +0 -0
  329. diffneusim/data/reference/x016run/x016run_v3p50_s6_r0.npz +0 -0
  330. diffneusim/data/reference/x016run/x016run_v3p50_s6_r1.npz +0 -0
  331. diffneusim/data/reference/x016run/x016run_v3p50_s6_r2.npz +0 -0
  332. diffneusim/data/reference/x016run/x016run_v3p50_s6_r3.npz +0 -0
  333. diffneusim/data/reference/x016run/x016run_v3p50_s7_l0.npz +0 -0
  334. diffneusim/data/reference/x016run/x016run_v3p50_s7_l1.npz +0 -0
  335. diffneusim/data/reference/x016run/x016run_v3p50_s7_l2.npz +0 -0
  336. diffneusim/data/reference/x016run/x016run_v3p50_s7_l3.npz +0 -0
  337. diffneusim/data/reference/x016run/x016run_v3p50_s7_r0.npz +0 -0
  338. diffneusim/data/reference/x016run/x016run_v3p50_s7_r1.npz +0 -0
  339. diffneusim/data/reference/x016run/x016run_v3p50_s7_r2.npz +0 -0
  340. diffneusim/data/reference/x016run/x016run_v3p50_s7_r3.npz +0 -0
  341. diffneusim/data/reference/x016run/x016run_v3p75_s0_l0.npz +0 -0
  342. diffneusim/data/reference/x016run/x016run_v3p75_s0_l1.npz +0 -0
  343. diffneusim/data/reference/x016run/x016run_v3p75_s0_l2.npz +0 -0
  344. diffneusim/data/reference/x016run/x016run_v3p75_s0_l3.npz +0 -0
  345. diffneusim/data/reference/x016run/x016run_v3p75_s0_r0.npz +0 -0
  346. diffneusim/data/reference/x016run/x016run_v3p75_s0_r1.npz +0 -0
  347. diffneusim/data/reference/x016run/x016run_v3p75_s0_r2.npz +0 -0
  348. diffneusim/data/reference/x016run/x016run_v3p75_s0_r3.npz +0 -0
  349. diffneusim/data/reference/x016run/x016run_v3p75_s1_l0.npz +0 -0
  350. diffneusim/data/reference/x016run/x016run_v3p75_s1_l1.npz +0 -0
  351. diffneusim/data/reference/x016run/x016run_v3p75_s1_l2.npz +0 -0
  352. diffneusim/data/reference/x016run/x016run_v3p75_s1_l3.npz +0 -0
  353. diffneusim/data/reference/x016run/x016run_v3p75_s1_r0.npz +0 -0
  354. diffneusim/data/reference/x016run/x016run_v3p75_s1_r1.npz +0 -0
  355. diffneusim/data/reference/x016run/x016run_v3p75_s1_r2.npz +0 -0
  356. diffneusim/data/reference/x016run/x016run_v3p75_s1_r3.npz +0 -0
  357. diffneusim/data/reference/x016run/x016run_v3p75_s2_l0.npz +0 -0
  358. diffneusim/data/reference/x016run/x016run_v3p75_s2_l1.npz +0 -0
  359. diffneusim/data/reference/x016run/x016run_v3p75_s2_l2.npz +0 -0
  360. diffneusim/data/reference/x016run/x016run_v3p75_s2_l3.npz +0 -0
  361. diffneusim/data/reference/x016run/x016run_v3p75_s2_r0.npz +0 -0
  362. diffneusim/data/reference/x016run/x016run_v3p75_s2_r1.npz +0 -0
  363. diffneusim/data/reference/x016run/x016run_v3p75_s2_r2.npz +0 -0
  364. diffneusim/data/reference/x016run/x016run_v3p75_s2_r3.npz +0 -0
  365. diffneusim/data/reference/x016run/x016run_v3p75_s3_l0.npz +0 -0
  366. diffneusim/data/reference/x016run/x016run_v3p75_s3_l1.npz +0 -0
  367. diffneusim/data/reference/x016run/x016run_v3p75_s3_l2.npz +0 -0
  368. diffneusim/data/reference/x016run/x016run_v3p75_s3_l3.npz +0 -0
  369. diffneusim/data/reference/x016run/x016run_v3p75_s3_r0.npz +0 -0
  370. diffneusim/data/reference/x016run/x016run_v3p75_s3_r1.npz +0 -0
  371. diffneusim/data/reference/x016run/x016run_v3p75_s3_r2.npz +0 -0
  372. diffneusim/data/reference/x016run/x016run_v3p75_s3_r3.npz +0 -0
  373. diffneusim/data/reference/x016run/x016run_v3p75_s5_l0.npz +0 -0
  374. diffneusim/data/reference/x016run/x016run_v3p75_s5_l1.npz +0 -0
  375. diffneusim/data/reference/x016run/x016run_v3p75_s5_l2.npz +0 -0
  376. diffneusim/data/reference/x016run/x016run_v3p75_s5_l3.npz +0 -0
  377. diffneusim/data/reference/x016run/x016run_v3p75_s5_r0.npz +0 -0
  378. diffneusim/data/reference/x016run/x016run_v3p75_s5_r1.npz +0 -0
  379. diffneusim/data/reference/x016run/x016run_v3p75_s5_r2.npz +0 -0
  380. diffneusim/data/reference/x016run/x016run_v3p75_s5_r3.npz +0 -0
  381. diffneusim/data/reference/x016run/x016run_v3p75_s6_l0.npz +0 -0
  382. diffneusim/data/reference/x016run/x016run_v3p75_s6_l1.npz +0 -0
  383. diffneusim/data/reference/x016run/x016run_v3p75_s6_l2.npz +0 -0
  384. diffneusim/data/reference/x016run/x016run_v3p75_s6_l3.npz +0 -0
  385. diffneusim/data/reference/x016run/x016run_v3p75_s6_r0.npz +0 -0
  386. diffneusim/data/reference/x016run/x016run_v3p75_s6_r1.npz +0 -0
  387. diffneusim/data/reference/x016run/x016run_v3p75_s6_r2.npz +0 -0
  388. diffneusim/data/reference/x016run/x016run_v3p75_s6_r3.npz +0 -0
  389. diffneusim/data/reference/x016run/x016run_v3p75_s7_l0.npz +0 -0
  390. diffneusim/data/reference/x016run/x016run_v3p75_s7_l1.npz +0 -0
  391. diffneusim/data/reference/x016run/x016run_v3p75_s7_l2.npz +0 -0
  392. diffneusim/data/reference/x016run/x016run_v3p75_s7_l3.npz +0 -0
  393. diffneusim/data/reference/x016run/x016run_v3p75_s7_r0.npz +0 -0
  394. diffneusim/data/reference/x016run/x016run_v3p75_s7_r1.npz +0 -0
  395. diffneusim/data/reference/x016run/x016run_v3p75_s7_r2.npz +0 -0
  396. diffneusim/data/reference/x016run/x016run_v3p75_s7_r3.npz +0 -0
  397. diffneusim/data/state_prior/lumbar_poly_fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc.npz +0 -0
  398. diffneusim/engine/__init__.py +0 -0
  399. diffneusim/engine/build_tag.py +52 -0
  400. diffneusim/engine/case_tables.py +46 -0
  401. diffneusim/engine/d16_body.py +80 -0
  402. diffneusim/engine/engine14.py +367 -0
  403. diffneusim/engine/gen_split.py +159 -0
  404. diffneusim/engine/hand_format.py +69 -0
  405. diffneusim/engine/live14.py +149 -0
  406. diffneusim/engine/phase_b_tree.py +137 -0
  407. diffneusim/engine/soft14.py +130 -0
  408. diffneusim/engine/soft_capi.py +373 -0
  409. diffneusim/engine/soft_engine.py +165 -0
  410. diffneusim/engine/step14.py +132 -0
  411. diffneusim/engine/tape_format.py +89 -0
  412. diffneusim/engine/x14cpu.py +163 -0
  413. diffneusim/env/__init__.py +0 -0
  414. diffneusim/env/absent.py +20 -0
  415. diffneusim/env/cpu14.py +105 -0
  416. diffneusim/env/e0loop14.py +224 -0
  417. diffneusim/env/env14.py +568 -0
  418. diffneusim/env/kin_contact14.py +193 -0
  419. diffneusim/env/mimic_sites_x14.json +366 -0
  420. diffneusim/env/old_count.py +78 -0
  421. diffneusim/env/rew14.py +114 -0
  422. diffneusim/env/rew14_hook.py +105 -0
  423. diffneusim/g1/__init__.py +1 -0
  424. diffneusim/g1/arm_a2.py +165 -0
  425. diffneusim/g1/arm_a3.py +576 -0
  426. diffneusim/g1/read_a3.py +79 -0
  427. diffneusim/g1/rg1_read.py +89 -0
  428. diffneusim/model/__init__.py +66 -0
  429. diffneusim/model/case.py +17 -0
  430. diffneusim/model/dnmodel.py +79 -0
  431. diffneusim/model/fuse_fixed.py +281 -0
  432. diffneusim/model/monitor.py +834 -0
  433. diffneusim/models/BODIES.toml +48 -0
  434. diffneusim/models/MANIFEST.toml +979 -0
  435. diffneusim/models/cases/G290/case.bin +0 -0
  436. diffneusim/models/cases/G290/case.json +1 -0
  437. diffneusim/models/cases/G356-SRC/case.bin +0 -0
  438. diffneusim/models/cases/G356-SRC/case.json +1 -0
  439. diffneusim/models/cases/G416/case.bin +0 -0
  440. diffneusim/models/cases/G416/case.json +1 -0
  441. diffneusim/models/cases/M290C-SRC/case.bin +0 -0
  442. diffneusim/models/cases/M290C-SRC/case.json +1 -0
  443. diffneusim/models/cases/M290R-SRC/case.bin +0 -0
  444. diffneusim/models/cases/M290R-SRC/case.json +1 -0
  445. diffneusim/models/cases/M356C-SRC/case.bin +0 -0
  446. diffneusim/models/cases/M356C-SRC/case.json +1 -0
  447. diffneusim/models/cases/M356R-SRC/case.bin +0 -0
  448. diffneusim/models/cases/M356R-SRC/case.json +1 -0
  449. diffneusim/models/cases/M416C-SRC/case.bin +0 -0
  450. diffneusim/models/cases/M416C-SRC/case.json +1 -0
  451. diffneusim/models/derived/d16_expanded_62f77a4bb16b1e67_mmfloor.xml +673 -0
  452. diffneusim/models/derived/d16_expanded_a1e8b196b2cd7b3c_mmfloor.xml +673 -0
  453. diffneusim/models/derived/d16_soft_law_019e20820f8633b9_mmfloor.json +7844 -0
  454. diffneusim/models/derived/d16_soft_law_62f77a4bb16b1e67_mmfloor.json +16855 -0
  455. diffneusim/models/derived/d16_soft_law_77dbb7213f26e821_mmfloor_rampsb3l_n6t12.json +7883 -0
  456. diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rampsb3l_n6t12.json +7883 -0
  457. diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rhlsd05_n6t12.json +7868 -0
  458. diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rhlsdef_n6t12.json +7868 -0
  459. diffneusim/models/derived/d16_soft_law_8989b60e44860c5b_mmfloor_rhlsmjd_n6t12.json +7868 -0
  460. diffneusim/models/derived/d16_soft_law_a1e8b196b2cd7b3c_mmfloor_rampsb3l_n6t12.json +16894 -0
  461. diffneusim/models/derived/d16_soft_law_a944653edd642082_mmfloor.json +12655 -0
  462. diffneusim/models/derived/d16_soft_law_a944653edd642082_mmfloor_rampsb3l_n6t12.json +12700 -0
  463. diffneusim/models/derived/unitree_g1_soft_law.json +15580 -0
  464. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.dnmodel +28913 -0
  465. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_qk.txt +1 -0
  466. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid.dnmodel +29202 -0
  467. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid_qk.txt +1 -0
  468. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_axfixlegs01.dnmodel +1 -0
  469. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.dnmodel +1 -0
  470. diffneusim/models/fullbody_contact_spinecoupled_armless_ball_lspine_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1_qk.txt +1 -0
  471. diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.dnmodel +46970 -0
  472. diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_qk.txt +1 -0
  473. diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.dnmodel +1 -0
  474. diffneusim/models/fullbody_contact_spinecoupled_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1_qk.txt +1 -0
  475. diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src.dnmodel +38570 -0
  476. diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_qk.txt +1 -0
  477. diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid.dnmodel +38923 -0
  478. diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_millard_stickspin_wrapvia_mtp60k25_trunkfix_toepair_n1_src_rigid_qk.txt +1 -0
  479. diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1.dnmodel +1 -0
  480. diffneusim/models/fullbody_contact_spinecoupled_fusedhand_ball_lspine_girdle_osimeq_stickspin_wrapvia_mtp60k25_trunkfix_calf2_pe_toepair_flsrc_n1_qk.txt +1 -0
  481. diffneusim/models/fullbody_meshes/1mc.stl +0 -0
  482. diffneusim/models/fullbody_meshes/2distph.stl +0 -0
  483. diffneusim/models/fullbody_meshes/2mc.stl +0 -0
  484. diffneusim/models/fullbody_meshes/2midph.stl +0 -0
  485. diffneusim/models/fullbody_meshes/2proxph.stl +0 -0
  486. diffneusim/models/fullbody_meshes/3distph.stl +0 -0
  487. diffneusim/models/fullbody_meshes/3mc.stl +0 -0
  488. diffneusim/models/fullbody_meshes/3midph.stl +0 -0
  489. diffneusim/models/fullbody_meshes/3proxph.stl +0 -0
  490. diffneusim/models/fullbody_meshes/4distph.stl +0 -0
  491. diffneusim/models/fullbody_meshes/4mc.stl +0 -0
  492. diffneusim/models/fullbody_meshes/4midph.stl +0 -0
  493. diffneusim/models/fullbody_meshes/4proxph.stl +0 -0
  494. diffneusim/models/fullbody_meshes/5distph.stl +0 -0
  495. diffneusim/models/fullbody_meshes/5mc.stl +0 -0
  496. diffneusim/models/fullbody_meshes/5midph.stl +0 -0
  497. diffneusim/models/fullbody_meshes/5proxph.stl +0 -0
  498. diffneusim/models/fullbody_meshes/NOTICE +2 -0
  499. diffneusim/models/fullbody_meshes/capitate.stl +0 -0
  500. diffneusim/models/fullbody_meshes/clavicle.stl +0 -0
  501. diffneusim/models/fullbody_meshes/hamate.stl +0 -0
  502. diffneusim/models/fullbody_meshes/hat_cervical.stl +0 -0
  503. diffneusim/models/fullbody_meshes/hat_jaw.stl +0 -0
  504. diffneusim/models/fullbody_meshes/hat_skull.stl +0 -0
  505. diffneusim/models/fullbody_meshes/humerus.stl +0 -0
  506. diffneusim/models/fullbody_meshes/l_bofoot.stl +0 -0
  507. diffneusim/models/fullbody_meshes/l_femur.stl +0 -0
  508. diffneusim/models/fullbody_meshes/l_fibula.stl +0 -0
  509. diffneusim/models/fullbody_meshes/l_foot.stl +0 -0
  510. diffneusim/models/fullbody_meshes/l_patella.stl +0 -0
  511. diffneusim/models/fullbody_meshes/l_pelvis.stl +0 -0
  512. diffneusim/models/fullbody_meshes/l_talus.stl +0 -0
  513. diffneusim/models/fullbody_meshes/l_tibia.stl +0 -0
  514. diffneusim/models/fullbody_meshes/lumbar1.stl +0 -0
  515. diffneusim/models/fullbody_meshes/lumbar2.stl +0 -0
  516. diffneusim/models/fullbody_meshes/lumbar3.stl +0 -0
  517. diffneusim/models/fullbody_meshes/lumbar4.stl +0 -0
  518. diffneusim/models/fullbody_meshes/lumbar5.stl +0 -0
  519. diffneusim/models/fullbody_meshes/lunate.stl +0 -0
  520. diffneusim/models/fullbody_meshes/pisiform.stl +0 -0
  521. diffneusim/models/fullbody_meshes/r_bofoot.stl +0 -0
  522. diffneusim/models/fullbody_meshes/r_femur.stl +0 -0
  523. diffneusim/models/fullbody_meshes/r_fibula.stl +0 -0
  524. diffneusim/models/fullbody_meshes/r_foot.stl +0 -0
  525. diffneusim/models/fullbody_meshes/r_patella.stl +0 -0
  526. diffneusim/models/fullbody_meshes/r_pelvis.stl +0 -0
  527. diffneusim/models/fullbody_meshes/r_talus.stl +0 -0
  528. diffneusim/models/fullbody_meshes/r_tibia.stl +0 -0
  529. diffneusim/models/fullbody_meshes/radius.stl +0 -0
  530. diffneusim/models/fullbody_meshes/sacrum.stl +0 -0
  531. diffneusim/models/fullbody_meshes/scaphoid.stl +0 -0
  532. diffneusim/models/fullbody_meshes/scapula.stl +0 -0
  533. diffneusim/models/fullbody_meshes/thoracic10_s.stl +0 -0
  534. diffneusim/models/fullbody_meshes/thoracic11_s.stl +0 -0
  535. diffneusim/models/fullbody_meshes/thoracic12_s.stl +0 -0
  536. diffneusim/models/fullbody_meshes/thoracic1_s.stl +0 -0
  537. diffneusim/models/fullbody_meshes/thoracic2_s.stl +0 -0
  538. diffneusim/models/fullbody_meshes/thoracic3_s.stl +0 -0
  539. diffneusim/models/fullbody_meshes/thoracic4_s.stl +0 -0
  540. diffneusim/models/fullbody_meshes/thoracic5_s.stl +0 -0
  541. diffneusim/models/fullbody_meshes/thoracic6_s.stl +0 -0
  542. diffneusim/models/fullbody_meshes/thoracic7_s.stl +0 -0
  543. diffneusim/models/fullbody_meshes/thoracic8_s.stl +0 -0
  544. diffneusim/models/fullbody_meshes/thoracic9_s.stl +0 -0
  545. diffneusim/models/fullbody_meshes/thorax.stl +0 -0
  546. diffneusim/models/fullbody_meshes/thumbdist.stl +0 -0
  547. diffneusim/models/fullbody_meshes/thumbprox.stl +0 -0
  548. diffneusim/models/fullbody_meshes/trapezium.stl +0 -0
  549. diffneusim/models/fullbody_meshes/trapezoid.stl +0 -0
  550. diffneusim/models/fullbody_meshes/triquetrum.stl +0 -0
  551. diffneusim/models/fullbody_meshes/ulna.stl +0 -0
  552. diffneusim/models/source/myo_fullbody/UPSTREAM.md +91 -0
  553. diffneusim/models/source/myoleg/UPSTREAM.md +52 -0
  554. diffneusim/models/source/unitree_g1/LICENSE.mjlab +202 -0
  555. diffneusim/models/source/unitree_g1/UPSTREAM.md +38 -0
  556. diffneusim/models/source/unitree_g1/assets/head_link.STL +0 -0
  557. diffneusim/models/source/unitree_g1/assets/left_ankle_pitch_link.STL +0 -0
  558. diffneusim/models/source/unitree_g1/assets/left_ankle_roll_link.STL +0 -0
  559. diffneusim/models/source/unitree_g1/assets/left_elbow_link.STL +0 -0
  560. diffneusim/models/source/unitree_g1/assets/left_hip_pitch_link.STL +0 -0
  561. diffneusim/models/source/unitree_g1/assets/left_hip_roll_link.STL +0 -0
  562. diffneusim/models/source/unitree_g1/assets/left_hip_yaw_link.STL +0 -0
  563. diffneusim/models/source/unitree_g1/assets/left_knee_link.STL +0 -0
  564. diffneusim/models/source/unitree_g1/assets/left_rubber_hand.STL +0 -0
  565. diffneusim/models/source/unitree_g1/assets/left_shoulder_pitch_link.STL +0 -0
  566. diffneusim/models/source/unitree_g1/assets/left_shoulder_roll_link.STL +0 -0
  567. diffneusim/models/source/unitree_g1/assets/left_shoulder_yaw_link.STL +0 -0
  568. diffneusim/models/source/unitree_g1/assets/left_wrist_pitch_link.STL +0 -0
  569. diffneusim/models/source/unitree_g1/assets/left_wrist_roll_link.STL +0 -0
  570. diffneusim/models/source/unitree_g1/assets/left_wrist_yaw_link.STL +0 -0
  571. diffneusim/models/source/unitree_g1/assets/logo_link.STL +0 -0
  572. diffneusim/models/source/unitree_g1/assets/pelvis.STL +0 -0
  573. diffneusim/models/source/unitree_g1/assets/pelvis_contour_link.STL +0 -0
  574. diffneusim/models/source/unitree_g1/assets/right_ankle_pitch_link.STL +0 -0
  575. diffneusim/models/source/unitree_g1/assets/right_ankle_roll_link.STL +0 -0
  576. diffneusim/models/source/unitree_g1/assets/right_elbow_link.STL +0 -0
  577. diffneusim/models/source/unitree_g1/assets/right_hip_pitch_link.STL +0 -0
  578. diffneusim/models/source/unitree_g1/assets/right_hip_roll_link.STL +0 -0
  579. diffneusim/models/source/unitree_g1/assets/right_hip_yaw_link.STL +0 -0
  580. diffneusim/models/source/unitree_g1/assets/right_knee_link.STL +0 -0
  581. diffneusim/models/source/unitree_g1/assets/right_rubber_hand.STL +0 -0
  582. diffneusim/models/source/unitree_g1/assets/right_shoulder_pitch_link.STL +0 -0
  583. diffneusim/models/source/unitree_g1/assets/right_shoulder_roll_link.STL +0 -0
  584. diffneusim/models/source/unitree_g1/assets/right_shoulder_yaw_link.STL +0 -0
  585. diffneusim/models/source/unitree_g1/assets/right_wrist_pitch_link.STL +0 -0
  586. diffneusim/models/source/unitree_g1/assets/right_wrist_roll_link.STL +0 -0
  587. diffneusim/models/source/unitree_g1/assets/right_wrist_yaw_link.STL +0 -0
  588. diffneusim/models/source/unitree_g1/assets/torso_link_rev_1_0.STL +0 -0
  589. diffneusim/models/source/unitree_g1/assets/waist_roll_link_rev_1_0.STL +0 -0
  590. diffneusim/models/source/unitree_g1/assets/waist_yaw_link_rev_1_0.STL +0 -0
  591. diffneusim/models/source/unitree_g1/dump_mjlab_reference.py +30 -0
  592. diffneusim/models/source/unitree_g1/g1.xml +308 -0
  593. diffneusim/models/source/unitree_g1/g1_constants.py +298 -0
  594. diffneusim/models/source/unitree_g1/mjlab_compiled_reference.json +857 -0
  595. diffneusim/models/unitree_g1.dnmodel +4393 -0
  596. diffneusim/models/unitree_g1_selfcol.dnmodel +20824 -0
  597. diffneusim/rl/__init__.py +2 -0
  598. diffneusim/rl/dynsyn_layer.py +146 -0
  599. diffneusim/rl/footstep_plan.py +337 -0
  600. diffneusim/rl/g1_bm_env.py +572 -0
  601. diffneusim/rl/g1_bm_eval.py +168 -0
  602. diffneusim/rl/g1_bm_fused.py +275 -0
  603. diffneusim/rl/g1_bm_ppo.py +622 -0
  604. diffneusim/rl/g1_bm_sapo.py +551 -0
  605. diffneusim/rl/g1_ppo.py +395 -0
  606. diffneusim/rl/g1_sapo_soft.py +240 -0
  607. diffneusim/rl/g1_soft_env.py +452 -0
  608. diffneusim/rl/g1_soft_grad.py +145 -0
  609. diffneusim/rl/geyer_curves_torch.py +108 -0
  610. diffneusim/rl/gpu_fullbody_vec_env.py +1241 -0
  611. diffneusim/rl/imitation.py +2027 -0
  612. diffneusim/rl/imitation_reward_v2.py +248 -0
  613. diffneusim/rl/imitation_reward_v3.py +349 -0
  614. diffneusim/rl/latent_task.py +175 -0
  615. diffneusim/rl/llc_reward.py +316 -0
  616. diffneusim/rl/millard_curves_torch.py +154 -0
  617. diffneusim/rl/mirror_symmetry.py +212 -0
  618. diffneusim/rl/model_path.py +35 -0
  619. diffneusim/rl/mvae_recon.py +123 -0
  620. diffneusim/rl/nets_shac.py +599 -0
  621. diffneusim/rl/reset_pool.py +154 -0
  622. diffneusim/rl/sapo_capture.py +873 -0
  623. diffneusim/rl/sapo_vec.py +1051 -0
  624. diffneusim/rl/shac_vec.py +346 -0
  625. diffneusim/rl/state_prior.py +151 -0
  626. diffneusim/rl/step_library.py +105 -0
  627. diffneusim/rl/task_walk_env.py +1793 -0
  628. diffneusim/rl/task_walk_reward.py +3300 -0
  629. diffneusim/run.py +23 -0
  630. diffneusim/run_env.py +46 -0
  631. diffneusim/tasks/__init__.py +147 -0
  632. diffneusim/tasks/legacy_names.py +63 -0
  633. diffneusim/tasks/paths.py +79 -0
  634. diffneusim/tasks/settings.py +202 -0
  635. diffneusim/third_party/instantmimic_947430ee/LICENSE +202 -0
  636. diffneusim/third_party/instantmimic_947430ee/NOTICE +19 -0
  637. diffneusim/third_party/instantmimic_947430ee/README.md +31 -0
  638. diffneusim/third_party/instantmimic_947430ee/instantmimic/envs/unitree_g1/tasks/beyondmimic_tracking/benchmark_protocol.py +106 -0
  639. diffneusim/third_party/instantmimic_947430ee/instantmimic/envs/unitree_g1/tasks/beyondmimic_tracking/metrics.py +214 -0
  640. diffneusim/third_party/instantmimic_947430ee/instantmimic/envs/unitree_g1/tasks/beyondmimic_tracking/reference.py +513 -0
  641. diffneusim/third_party/instantmimic_947430ee/instantmimic/motion/quaternion.py +193 -0
  642. diffneusim/train/__init__.py +0 -0
  643. diffneusim/train/eval_ckpt.py +239 -0
  644. diffneusim/train/eval_mimic.py +133 -0
  645. diffneusim/train/gait_report.py +203 -0
  646. diffneusim/train/gcot_chain.py +51 -0
  647. diffneusim/train/levers.py +135 -0
  648. diffneusim/train/masked_reset.py +314 -0
  649. diffneusim/train/rl_algorithm_suite.py +917 -0
  650. diffneusim/train/train14.py +240 -0
  651. diffneusim/train/train_tw14.py +674 -0
  652. diffneusim/viz/__init__.py +5 -0
  653. diffneusim/viz/__main__.py +41 -0
  654. diffneusim/viz/camera.py +115 -0
  655. diffneusim/viz/dnrec.py +118 -0
  656. diffneusim/viz/dnrec_io.py +686 -0
  657. diffneusim/viz/hud.py +565 -0
  658. diffneusim/viz/meshes.py +458 -0
  659. diffneusim/viz/play.py +237 -0
  660. diffneusim/viz/record.py +74 -0
  661. diffneusim/viz/render.py +1402 -0
  662. diffneusim/viz/renderer.py +268 -0
  663. diffneusim/viz/rl_env_render.py +635 -0
  664. diffneusim/viz/snapshot.py +54 -0
  665. diffneusim/viz/strobe.py +124 -0
  666. diffneusim/viz/to_mp4.py +58 -0
  667. diffneusim/viz/ui.py +481 -0
  668. diffneusim/viz/viewer.py +2086 -0
  669. diffneusim-1.0.0.dist-info/METADATA +226 -0
  670. diffneusim-1.0.0.dist-info/RECORD +682 -0
  671. diffneusim-1.0.0.dist-info/WHEEL +5 -0
  672. diffneusim-1.0.0.dist-info/licenses/LICENSE +201 -0
  673. diffneusim-1.0.0.dist-info/licenses/LICENSES/BSD-3-Clause-NC-ARMS-hand-wrist-4.3.txt +20 -0
  674. diffneusim-1.0.0.dist-info/licenses/LICENSES/BSD-3-Clause-NC-MoBL-ARMS.txt +25 -0
  675. diffneusim-1.0.0.dist-info/licenses/LICENSES/CC-BY-3.0-OpenSim-geometry.txt +25 -0
  676. diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Christophy2012-lumbarspine.txt +10 -0
  677. diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Lai2017-model-high-flex.txt +10 -0
  678. diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Lee2015-hand_muscle.txt +11 -0
  679. diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Rajagopal2016-full_body.txt +11 -0
  680. diffneusim-1.0.0.dist-info/licenses/LICENSES/MIT-Uhlrich2022-fbmodpassivecal.txt +10 -0
  681. diffneusim-1.0.0.dist-info/licenses/NOTICE +274 -0
  682. diffneusim-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,576 @@
1
+ """A3's runner (tools/g1_seconds/PREREG_A3.md): InstantMimic's BeyondMimic side-kick task on our engine (g1_bm_env.BMTrack in its
2
+ differentiable mode, through the G1 adjoint) trained by OUR first-order trainer (g1_bm_sapo.SapoBM: SAPO with the knobs and EMA).
3
+ arm_a2.py's pattern, with A2's clock, checkpoints and scoring unchanged:
4
+ clock CLOCK_MONOTONIC_RAW with a device sync after every update; EVERY update counts, the first included (nothing excluded but
5
+ the checkpoint saves and the scoring, which InstantMimic's accounting excludes too)
6
+ update one H-step BPTT window of every world, the actor step, the temperature step, the critic regression (one window per update)
7
+ checkpoints every --ckpt-every updates (default 100): the trainer's snapshot (actor, its EMA shadow, critic, optimisers, normalisers),
8
+ saved after the clock stops, with the active seconds
9
+ scoring after training, in the same warm process: InstantMimic's evaluate protocol (g1_bm_eval.evaluate) on every checkpoint, a
10
+ fresh evaluate-mode env per checkpoint with the same seed (1,024 worlds, sampling start, pushes off, observation and reset
11
+ noise on, the run's DR), seeded right before the reset, as A2; the EMA actor's mean first (the primary), then the raw actor's
12
+ output <out>/train.jsonl (per update: the stats, the gradient-health counts grad_clipped / grad_nonfinite / grad_rows, windows),
13
+ <out>/checkpoint_iter_<N>.pt, <out>/eval.jsonl (per checkpoint and actor: iteration, active_s, which, their metrics),
14
+ <out>/meta.json
15
+ python tools/g1_seconds/arm_a3.py --npz <their side kick npz> --out DIR [--seed 42] [--n 1024] [--H 64] [--iters 3000]
16
+ [--kappa 2.0] [--ship/--nodr] [--cpu] [--dry] [--no-eval] [--eval-n 1024] [--score ema,raw]
17
+ [--easy-every 10 --easy-dense-until 1000 --easy-sparse-every 100 --easy-score ema,raw] (PREREG_E1, outside the clock)
18
+ score-only (the review / line 23, 11-11: a run killed at its chain's cap before its in-process scoring): the SAME scoring loop (score()
19
+ below) on <out>/checkpoint_iter_*.pt in iteration order, in one warm process; seed, ship, H and the config from <out>/meta.json, each
20
+ checkpoint's active_s from its own dict; rows marked scored_after_run; then read_a3's three criteria. Refuses an existing eval file.
21
+ python tools/g1_seconds/arm_a3.py --out DIR --score-only [--dry] [--cpu] [--eval-n 1024] [--score ema,raw] [--eval-file eval.jsonl]
22
+ (--score-only --dry: the chain's CHECK_ONLY; meta.json read, every checkpoint loaded on the CPU and checked, no engine)"""
23
+ import argparse
24
+ import faulthandler
25
+ import json
26
+ import os
27
+ import pathlib
28
+ import sys
29
+ import time
30
+
31
+ import torch
32
+
33
+ # (3a) was: sys.path.insert(0, str(ROOT / "python"))
34
+ from diffneusim.rl import g1_bm_env as B # noqa: E402
35
+ from diffneusim.rl import g1_soft_env as G # noqa: E402
36
+
37
+
38
+ def raw_now():
39
+ return time.clock_gettime(time.CLOCK_MONOTONIC_RAW)
40
+
41
+
42
+ def check_aflags(bad, n, H, max_frac):
43
+ """Session the overflow fix (c): the adjoint's kShellBadRecord world-steps in one update (a substep whose tape record overflowed, its
44
+ VJP the identity of the forward's hold). Fail fast above max_frac of the update's n x H world-steps (the review's tentative 1%); below,
45
+ the update is kept (those worlds' gradient is the hold's, finite). Returns the fraction."""
46
+ frac = bad / float(n * H)
47
+ assert frac <= max_frac, (f"the adjoint flagged {bad} of {n * H} world-steps with kShellBadRecord ({100 * frac:.2f}% > "
48
+ f"{100 * max_frac:.2f}%): overflowed tape records, stopping")
49
+ return frac
50
+
51
+
52
+ EASY_N, EASY_STEPS, EASY_PASS = 32, 296, 0.9 # PREREG_E1: a0_neu.sh's BENCH (num_envs 32, steps 296, success_rate 0.9)
53
+ EASY_SIGMA = 1e-6 # PREREG_E1 Amendment 1: each benchmark world's start perturbation, N(0, sigma)
54
+ RG1_SECONDARY = { # PREREG_RG1 Amendment 2 (secondary readouts, the same rows): each with the 29 / 32 perturbed rule
55
+ "mpkpe_107": lambda r: r["mpkpe"] <= 0.107, # BeyondMimic's published MPKPE (mjlab's 107 mm)
56
+ "primary_thresholds": lambda r: (r["mpkpe"] <= 0.120 and r["r_mpkpe"] <= 0.033 and r["ee_pos_error"] <= 0.052 # the ship tables'
57
+ and r["ee_ori_error"] <= 0.180), # PRIMARY thresholds (benchmark_protocol.py)
58
+ }
59
+ RG1_SECONDARY_EVERY = 50 # after the primary pass, the remaining secondary rules every 50 updates / iterations
60
+ RG1_MPKPE_BAR = 0.0805 # PREREG_RG1: the worst of A1c's three crossing MPKPEs (80.5 / 49.6 / 72.4 mm, night chain
61
+ # 11-10 on their file, g1_soft_eval's MPKPE), so every A1c crossing met it
62
+
63
+
64
+ class ActionPathProbe:
65
+ """The training-path check (the review, RUN290's lesson) for an action-mapping knob: a ONE-SHOT wrapper on the training env's
66
+ lawmap.ctrl, the call BMTrack.step makes with the PD target. On the first training step (update 1, eager, before any capture) it
67
+ recovers the base pose the env really used (target - action x scale + encoder bias) and compares it with the command frame's
68
+ reference pose and with the default pose; then it removes itself. read() returns the two max abs differences and the verdict, and
69
+ asserts the base matches the mode the run was launched in (residual or default)."""
70
+
71
+ def __init__(self, env, residual):
72
+ self.env, self.residual, self.res, self.lm = env, bool(residual), None, env.lm
73
+ orig = env.lm.ctrl
74
+
75
+ def ctrl(target):
76
+ if self.res is None:
77
+ e = self.env
78
+ with torch.no_grad():
79
+ base = target.detach() - e.action.detach() * e.action_scale + e.encoder_bias
80
+ ref = e.m.joint_pos[e.time].to(base.dtype)
81
+ self.res = dict(d_reference=float((base - ref).abs().max()), d_default=float((base - e.q_default).abs().max()))
82
+ del self.lm.ctrl # one shot: the lawmap's own method again, before any capture
83
+ return orig(target)
84
+ env.lm.ctrl = ctrl
85
+
86
+ def skip(self, reason):
87
+ """stand down before any step (a captured resume: the first step runs inside the capture, where the probe's host read is a
88
+ synchronizing call); the resumed run's mode is the original run's own, from its meta.json"""
89
+ assert self.res is None, "the probe already fired"
90
+ del self.lm.ctrl
91
+ self.res = dict(skipped=reason)
92
+
93
+ def read(self):
94
+ assert self.res is not None, "the probe saw no training step"
95
+ if "skipped" in self.res:
96
+ return dict(self.res, residual=self.residual)
97
+ r = dict(self.res, residual=self.residual)
98
+ want, other = ("d_reference", "d_default") if self.residual else ("d_default", "d_reference")
99
+ assert r[want] <= 1e-5 < r[other] or r[want] <= 1e-5 and r[other] <= 1e-5, ("the training env's PD base is not the launched mode's", r)
100
+ return r
101
+
102
+
103
+ class EasyTrack(B.BMTrack):
104
+ """PREREG_E1 Amendment 1 (the review, the design rule that an unavoidable asymmetry goes against us): our engine's deterministic-start
105
+ worlds are bitwise identical (one rollout), MuJoCo Warp's diverge (its contact rows follow an atomic counter). So every world's
106
+ reference reset gets its own fixed perturbation, N(0, sigma) on the root position, the joint positions and every velocity (the
107
+ root quaternion kept), drawn ONCE from a dedicated generator seeded with the run's seed: the same perturbation at every benchmark
108
+ call and every checkpoint, and no draw from the global RNG. Applied after their perturb_reference_state, so the frames, the
109
+ command and the observation of the reset all see it (BMTrack._reset_worlds refreshes the frames after this call)."""
110
+
111
+ def __init__(self, *args, sigma, noise_seed, **kw):
112
+ super().__init__(*args, **kw)
113
+ g = torch.Generator(device="cpu").manual_seed(int(noise_seed))
114
+ dq = sigma * torch.randn(self.n, G.NQ, generator=g, dtype=torch.float64)
115
+ dq[:, 3:7] = 0.0
116
+ dv = sigma * torch.randn(self.n, G.NV, generator=g, dtype=torch.float64)
117
+ self.start_dq, self.start_dv = dq.to(self.dev, self.dt), dv.to(self.dev, self.dt)
118
+
119
+ def _write_reference_state(self, mask):
120
+ super()._write_reference_state(mask)
121
+ mk = mask.view(-1, 1)
122
+ self.qpos = torch.where(mk, self.qpos + self.start_dq, self.qpos)
123
+ self.qvel = torch.where(mk, self.qvel + self.start_dv, self.qvel)
124
+
125
+
126
+ @torch.no_grad()
127
+ def easy_bench(env, act, steps=EASY_STEPS, mpkpe=False):
128
+ """PREREG_E1's easy rule, their trainer benchmark's (InstantMimic 947430ee, train/benchmark_runner.py:850-912 with validity and
129
+ success 'full_horizon'; the rate at :719-722), as A0-nodr's 11-10 first pass ran it (a0_neu.sh's BENCH): every world reset to frame
130
+ 0 with no reset or observation noise and no DR or pushes (the env given), the mean action, and a world FAILS when it is done
131
+ (terminated or truncated) at a step count below `steps`; success_rate = the worlds never failed / all worlds. Stops early once
132
+ every world has failed (the rest cannot change the rate). Draws no RNG: the CPU and CUDA generator states are asserted unchanged.
133
+ mpkpe=True (PREREG_RG1) also accumulates their BeyondMimic metrics over the same rollouts, as their evaluate does (g1_bm_eval: the
134
+ reference snapshotted before each step, the robot state after it, their accumulator with the env's dones; at step `steps` every
135
+ world still running is closed as truncated): MPKPE and r_mpkpe are their per-episode time means over each world's steps, then the
136
+ mean over the worlds."""
137
+ cpu0 = torch.get_rng_state()
138
+ cu0 = torch.cuda.get_rng_state_all() if torch.cuda.is_available() else []
139
+ actor = env.reset_all()["actor"]
140
+ alive = torch.ones(env.n, dtype=torch.bool, device=actor.device)
141
+ first_fail, k = None, 0
142
+ acc = None
143
+ if mpkpe:
144
+ from diffneusim.rl import g1_bm_eval as E
145
+ acc = E.BeyondMimicBenchmarkAccumulator(num_envs=env.n, end_effector_indices=env.benchmark_end_effector_indices, device=actor.device)
146
+ for k in range(1, steps + 1):
147
+ ref = E._check_reference(env.snapshot_benchmark_reference(), env.n, env.act_dim) if acc is not None else None
148
+ out = env.step(act(actor))
149
+ done = out["terminated"] | out["truncated"]
150
+ if acc is not None:
151
+ rob = E._check_robot(env.get_benchmark_robot_state(), env.n, env.act_dim)
152
+ acc.update(reference=ref, robot_body_position_world=rob["body_position_world"],
153
+ robot_body_quaternion_world=rob["body_quaternion_world"], robot_joint_velocity=rob["joint_velocity"])
154
+ acc.mark_dones(terminated=out["terminated"], truncated=out["truncated"] | (k == steps))
155
+ if k < steps:
156
+ if first_fail is None and bool((alive & done).any()):
157
+ first_fail = k
158
+ alive = alive & ~done
159
+ if not bool(alive.any()):
160
+ break
161
+ actor = out["actor"]
162
+ assert torch.equal(torch.get_rng_state(), cpu0), "the easy benchmark drew from the CPU RNG"
163
+ assert all(torch.equal(a, b) for a, b in zip(torch.cuda.get_rng_state_all() if cu0 else [], cu0)), "it drew from the CUDA RNG"
164
+ ns = int(alive.sum().item())
165
+ r = dict(success_rate=ns / env.n, n_success=ns, n=int(env.n), steps_run=k, first_fail_step=first_fail)
166
+ if acc is not None:
167
+ assert bool(acc.done.all()), "a world left open by the easy benchmark's accumulator"
168
+ m = acc.finalize()
169
+ r.update({k: float(v) for k, v in m.items() if isinstance(v, (int, float))}) # their metrics: mpkpe, r_mpkpe, ee errors, ...
170
+ return r
171
+
172
+
173
+ class Easy:
174
+ """PREREG_E1's in-run easy benchmark, outside the clock (as their benchmark time is outside their active time): every `every`
175
+ updates up to `dense_until`, then every `sparse_every`, each actor in `which` until its first pass (success_rate >= EASY_PASS).
176
+ Rows go to <out>/easy.jsonl: it, active_s, which, the rule's counts, wall_s."""
177
+
178
+ def __init__(self, env, agent, which, every, dense_until, sparse_every, path, rows=(), mpkpe_bar=None, acts=None, on_pass=None,
179
+ secondary=None, secondary_every=None):
180
+ """mpkpe_bar (PREREG_RG1): the pass also needs MPKPE <= the bar on the same rollouts. acts: {name: mean-action function} (default:
181
+ agent.act_mean(o, which=name), SapoBM's). on_pass(name, it, active_s): called once at each actor's first pass (the crossing
182
+ checkpoint)."""
183
+ self.env, self.agent, self.which, self.path = env, agent, list(which), path
184
+ self.every, self.dense_until, self.sparse_every = int(every), int(dense_until), int(sparse_every)
185
+ self.mpkpe_bar, self.on_pass = mpkpe_bar, on_pass
186
+ self.acts = acts or {w: (lambda o, _w=w: agent.act_mean(o, which=_w)) for w in self.which}
187
+ assert set(self.which) <= set(self.acts), (self.which, sorted(self.acts))
188
+ self.passed = {r["which"] for r in rows if r["passed"]}
189
+ # PREREG_RG1 Amendment 2: secondary rules {name: predicate on a row}, each also needing the rate; an actor past its primary pass
190
+ # keeps being benchmarked every `secondary_every` until every secondary rule has crossed once
191
+ self.secondary, self.secondary_every = dict(secondary or {}), int(secondary_every or 0)
192
+ self.sec_passed = {(r["which"], k) for r in rows for k, v in r.get("secondary", {}).items() if v}
193
+
194
+ def _sec_open(self, w):
195
+ return [k for k in self.secondary if (w, k) not in self.sec_passed]
196
+
197
+ def passes(self, r):
198
+ return r["success_rate"] >= EASY_PASS and (self.mpkpe_bar is None or r["mpkpe"] <= self.mpkpe_bar)
199
+
200
+ def due(self, it):
201
+ k = self.every if it <= self.dense_until else self.sparse_every
202
+ out = [w for w in self.which if w not in self.passed] if it % k == 0 else []
203
+ if self.secondary_every and it % self.secondary_every == 0:
204
+ out += [w for w in self.which if w in self.passed and self._sec_open(w) and w not in out]
205
+ return out
206
+
207
+ def run(self, it, active_s):
208
+ todo = self.due(it)
209
+ with open(self.path, "a") as f:
210
+ for w in todo:
211
+ t0 = raw_now()
212
+ r = easy_bench(self.env, self.acts[w], mpkpe=self.mpkpe_bar is not None)
213
+ ok = self.passes(r)
214
+ sec = {k: bool(r["success_rate"] >= EASY_PASS and f(r)) for k, f in self.secondary.items()}
215
+ for k, v in sec.items():
216
+ if v:
217
+ self.sec_passed.add((w, k))
218
+ row = dict(it=it, active_s=active_s, which=w, **r, passed=ok, mpkpe_bar=self.mpkpe_bar, wall_s=raw_now() - t0,
219
+ **({"secondary": sec} if self.secondary else {}))
220
+ f.write(json.dumps(row) + "\n")
221
+ f.flush()
222
+ if ok and w not in self.passed:
223
+ self.passed.add(w)
224
+ print(f"EASY PASS {w} at update {it}, active {active_s:.2f} s: {json.dumps(r)}", flush=True)
225
+ if self.on_pass is not None:
226
+ self.on_pass(w, it, active_s)
227
+
228
+
229
+ def score(agent, ckpts, m, lm, ev_law, eval_n, ship, dev, dt, es, which, path, extra=None, com_dr=False, com_scale=1.0, residual=False):
230
+ """The scoring loop, shared by the in-process path and --score-only: per checkpoint the policy loaded, then per actor a fresh
231
+ evaluate-mode env with the same seed (the same DR draws), seeded right before the reset, as their evaluate.py."""
232
+ from diffneusim.rl import g1_bm_eval as E
233
+ with open(path, "w") as f:
234
+ for it, act_s, p in ckpts:
235
+ agent.load_policy(torch.load(p, weights_only=False)["snapshot"])
236
+ for w in which:
237
+ ev_env = B.BMTrack(ev_law, m, lm, eval_n, ship=ship, device=dev, dtype=dt, seed=es, sampling="start", pushes=False,
238
+ com_dr=com_dr, com_scale=com_scale, residual=residual) # the run's DR, as their evaluate takes the checkpoint's (the CoM draw included)
239
+ E.set_seed(es)
240
+ t0 = raw_now()
241
+ r = E.evaluate(ev_env, lambda o, _w=w: agent.act_mean(o, which=_w))
242
+ f.write(json.dumps(dict(iteration=it, active_s=act_s, which=w, eval_wall_s=raw_now() - t0, **r, **(extra or {})),
243
+ default=float) + "\n")
244
+ f.flush()
245
+ print(f"iter {it} active {act_s:.1f} s {w}: {json.dumps(r, default=float)[:200]}", flush=True)
246
+
247
+
248
+ def read_criteria(out):
249
+ """read_a3's three crossing rules (PREREG_A3 Amendment 1) on <out>/eval.jsonl, printed one line per actor."""
250
+ here = str(pathlib.Path(__file__).resolve().parent) # explicit: python -I (3.11+) does not put the script's directory on sys.path
251
+ if here not in sys.path:
252
+ sys.path.insert(0, here)
253
+ from diffneusim.g1 import read_a3
254
+ for w, res in read_a3.read(out).items():
255
+ print("READ_A3 " + json.dumps(dict(which=w, primary=res["primary"], secondary=res["secondary"], third=res["third"]), default=float),
256
+ flush=True)
257
+
258
+
259
+ def score_only(a, which):
260
+ """--out alone suffices: seed, ship, n, H, the npz and the config come from <out>/meta.json; train.jsonl is never needed (a run killed
261
+ at its cap ends mid-run, with no final s_per_iter line)."""
262
+ out = pathlib.Path(a.out)
263
+ meta = json.loads((out / "meta.json").read_text())
264
+ npz = a.npz or meta["npz"]
265
+ assert pathlib.Path(npz).is_file(), f"the motion {npz} (from {'--npz' if a.npz else 'meta.json'}) is not a file"
266
+ ef = out / a.eval_file
267
+ assert not (ef.exists() and ef.stat().st_size > 0), f"{ef} exists: score-only never overwrites an eval file"
268
+ ckpts = []
269
+ for p in out.glob("checkpoint_iter_*.pt"):
270
+ ck = torch.load(p, weights_only=False, map_location="cpu" if (a.dry or a.cpu) else None)
271
+ assert int(ck["it"]) == int(p.stem.rsplit("_", 1)[1]) and ck["seed"] == meta["seed"] and ck["ship"] == meta["ship"], p
272
+ sn = ck["snapshot"]
273
+ assert {"actor", "actor_ema", "obs_rms", "A", "cfg"} <= set(sn) and sn["actor_ema"] is not None, f"{p}: not a SapoBM snapshot"
274
+ assert sn["cfg"]["H"] == meta["H"] and sn["A"].numel() == 29, p
275
+ ckpts.append((int(ck["it"]), float(ck["active_s"]), p))
276
+ ckpts.sort()
277
+ assert ckpts, f"no checkpoint_iter_*.pt in {out}"
278
+ if a.dry:
279
+ print(f"SCORE-ONLY DRY ok: {out}: {len(ckpts)} checkpoints load on the CPU, iterations {ckpts[0][0]}-{ckpts[-1][0]} (active "
280
+ f"{ckpts[-1][1]:.1f} s), seed {meta['seed']}, ship {meta['ship']}, n {meta['n']}, H {meta['H']}, score {which}, npz {npz}, "
281
+ f"eval file {ef.name} absent", flush=True)
282
+ return
283
+ from diffneusim.rl import g1_bm_sapo as S
284
+ dev = "cpu" if a.cpu else "cuda"
285
+ dt = torch.float64 if a.cpu else torch.float32
286
+ lm = G.LawMap(device=dev)
287
+ m = G.Motion(npz, lm, device=dev, dtype=dt)
288
+ eval_law = ((lambda k: G.CpuLaw(B.ROBOT_BODIES)) if a.cpu else
289
+ (lambda k: G.GpuLaw(k, B.ROBOT_BODIES, com_dr=bool(meta.get("com_dr", False))))) # the COMDR build when the run drew
290
+ n_agent = 2 # the agent only holds the policy; its env gives the dims and the action box
291
+ cfg = dict(meta["cfg"], n_env=n_agent)
292
+ env = B.BMTrack(eval_law(n_agent), m, lm, n_agent, ship=meta["ship"], device=dev, dtype=dt, seed=meta["seed"])
293
+ agent = S.SapoBM(env, cfg, seed=meta["seed"])
294
+ print(f"SCORE-ONLY {out}: {len(ckpts)} checkpoints, iterations {ckpts[0][0]}-{ckpts[-1][0]}, seed {meta['seed']}, ship {meta['ship']}, "
295
+ f"score {which}", flush=True)
296
+ score(agent, ckpts, m, lm, eval_law(a.eval_n), a.eval_n, meta["ship"], dev, dt, a.eval_seed or meta["seed"], which, ef,
297
+ extra=dict(scored_after_run=True, note="scored after the run (killed at the cap)"), com_dr=bool(meta.get("com_dr", False)), com_scale=float(meta.get("com_scale", 1.0)),
298
+ residual=bool(meta.get("residual", False)))
299
+ if a.eval_file == "eval.jsonl":
300
+ read_criteria(out)
301
+ print("A3 SCORE-ONLY DONE")
302
+
303
+
304
+ def main():
305
+ ap = argparse.ArgumentParser()
306
+ ap.add_argument("--npz", default=None, help="their side kick npz (required to train; score-only reads it from meta.json)")
307
+ ap.add_argument("--out", required=True)
308
+ ap.add_argument("--seed", type=int, default=42)
309
+ ap.add_argument("--n", type=int, default=1024)
310
+ ap.add_argument("--H", type=int, default=64)
311
+ ap.add_argument("--iters", type=int, default=3000)
312
+ ap.add_argument("--decay-iters", type=int, default=None, help="the linear lr decay's length (default: the trainer's CFG)")
313
+ ap.add_argument("--actor-lr", type=float, default=None, help="the actor's initial lr (default: the trainer's CFG, 2e-3); hub 13's s9")
314
+ ap.add_argument("--kappa", type=float, default=None, help="the per-env action-gradient clip factor (default: CFG's, E0's 2)")
315
+ ap.add_argument("--ckpt-every", type=int, default=100)
316
+ ap.add_argument("--nodr", action="store_true", help="the nodr variant (default: ship)")
317
+ ap.add_argument("--com-dr", action="store_true", help="InstantMimic's torso CoM draw in the ship DR (hub 13, 11-11; BMTrack com_dr: "
318
+ "needs a law with set_anchor_ipos_offset, session C's engine piece); the scorer env draws it too")
319
+ ap.add_argument("--residual", action="store_true", help="R-G1: residual actions (BMTrack residual: the command frame's "
320
+ "reference pose + action x their scale); every env of the run (training, scorer, easy benchmark) takes it")
321
+ ap.add_argument("--com-scale", type=float, default=1.0, help="gate knob: scales the CoM draw (0 must equal a --com-dr-off run)")
322
+ ap.add_argument("--cpu", action="store_true", help="the f64 CPU Jacobian law (a smoke at small n and H; no timing meaning)")
323
+ ap.add_argument("--dry", action="store_true", help="CHECK_ONLY: imports, the law map, the motion, the config; no engine")
324
+ ap.add_argument("--no-eval", action="store_true")
325
+ ap.add_argument("--eval-n", type=int, default=1024)
326
+ ap.add_argument("--eval-seed", type=int, default=None, help="default: the training seed (their evaluate.py takes the run's seed)")
327
+ ap.add_argument("--score", default="ema,raw", help="which actors each checkpoint is scored with, in order (ema = the primary)")
328
+ ap.add_argument("--reward-scale", type=float, default=None, help="diagnostic: the return and the critic's targets see K x reward")
329
+ ap.add_argument("--alpha-fixed", type=float, default=None, help="diagnostic: a fixed temperature, no temperature step")
330
+ ap.add_argument("--action-box", type=float, default=None, help="diagnostic: A_j = V for every joint (default: the model rule)")
331
+ ap.add_argument("--target-entropy", default=None, choices=("per_dim", "noise"),
332
+ help="diagnostic: 'noise' = LONG13's target from an action noise of --action-noise action units per joint")
333
+ ap.add_argument("--action-noise", type=float, default=None, help="with --target-entropy noise (default 0.1, SuperMimic Table A.5)")
334
+ ap.add_argument("--init-alpha", type=float, default=None, help="the temperature's start (default: CFG's 0.1)")
335
+ ap.add_argument("--segments", type=int, default=None, help="the window's autograd / CUDA-graph segments (default 1)")
336
+ ap.add_argument("--overflow-done", action="store_true", help="overflow-as-done (C's design, hub 13 11-11): an overflowed world is "
337
+ "truncated at that step and reset; default off")
338
+ ap.add_argument("--aflag-max-frac", type=float, default=0.01, help="fail fast when the adjoint's kShellBadRecord world-steps exceed "
339
+ "this fraction of an update's n x H (session C's overflow fix; the hub's tentative 1%%)")
340
+ ap.add_argument("--critic-iters", type=int, default=None, help="the critic's regression iterations per update (default: CFG's 4; "
341
+ "the minibatches per iteration unchanged)")
342
+ ap.add_argument("--capture", action="store_true", help="capture the window as a CUDA graph after update 1 (outside the clock, as "
343
+ "A1c / A2c; update 1 stays eager and on the clock); every later update replays it, the rest of the update eager")
344
+ ap.add_argument("--capture-warmup", type=int, default=2)
345
+ ap.add_argument("--fused", action="store_true", help="the old name of the default (the unification, 11-11: the compiled path IS "
346
+ "BMTrack.step, compile=True); accepted so old job lines run unchanged; refused with --eager")
347
+ ap.add_argument("--eager", action="store_true", help="opt out of the compiled training env (the user's rule 11-11: speed-ups are the "
348
+ "default); --cpu runs eager too (a Mac smoke; the compiled path's CPU equivalence is tools/g1_seconds/unify_eager_gate.py)")
349
+ ap.add_argument("--resume", action="store_true", help="continue <out>'s run from its resume.pt (the last checkpoint): every agent "
350
+ "and env tensor and both RNGs restored, active time carried; with --capture it captures before the first update")
351
+ ap.add_argument("--score-only", action="store_true", help="score <out>'s saved checkpoints (a run killed before its scoring)")
352
+ ap.add_argument("--eval-file", default="eval.jsonl", help="the eval rows' file name in <out> (score-only; the tests use another)")
353
+ ap.add_argument("--easy-every", type=int, default=0, help="PREREG_E1: the easy benchmark (easy_bench: 32 worlds from frame 0, no "
354
+ "noise, no DR or pushes, 296 steps) every K updates outside the clock, each actor until its first pass (0: off)")
355
+ ap.add_argument("--easy-dense-until", type=int, default=1000, help="after this update the easy benchmark runs every --easy-sparse-every")
356
+ ap.add_argument("--easy-sparse-every", type=int, default=100)
357
+ ap.add_argument("--easy-score", default="ema,raw", help="the actors the easy benchmark scores, in order")
358
+ ap.add_argument("--easy-mpkpe-bar", type=float, default=None, help="PREREG_RG1: the pass also needs MPKPE <= this (m) on the same "
359
+ "rollouts; arm_a3.RG1_MPKPE_BAR = 0.0805; at each actor's first pass, crossing_<actor>.pt is saved")
360
+ a = ap.parse_args()
361
+ from diffneusim.rl import g1_bm_sapo as S
362
+ cfg = dict(S.CFG, n_env=a.n, H=a.H)
363
+ if a.decay_iters is not None:
364
+ cfg["decay_iters"] = a.decay_iters
365
+ if a.actor_lr is not None:
366
+ cfg["actor_lr"] = a.actor_lr
367
+ if a.kappa is not None:
368
+ cfg["action_grad_clip"] = a.kappa
369
+ for k, v in (("reward_scale", a.reward_scale), ("alpha_fixed", a.alpha_fixed), ("action_box", a.action_box),
370
+ ("target_entropy", a.target_entropy), ("action_noise", a.action_noise), ("init_alpha", a.init_alpha),
371
+ ("segments", a.segments), ("critic_iterations", a.critic_iters)):
372
+ if v is not None: # recorded in cfg, so meta.json, resume and score-only carry it
373
+ cfg[k] = v
374
+ which = [w.strip() for w in a.score.split(",") if w.strip()]
375
+ assert which and all(w in ("ema", "raw") for w in which), a.score
376
+ if a.score_only:
377
+ score_only(a, which)
378
+ return
379
+ if a.resume: # everything from the run's own records: meta.json and resume.pt
380
+ meta = json.loads((pathlib.Path(a.out) / "meta.json").read_text())
381
+ a.npz, a.seed, a.n, a.H, a.nodr = meta["npz"], meta["seed"], meta["n"], meta["H"], not meta["ship"]
382
+ assert not a.com_dr or meta.get("com_dr", False), "--com-dr on a run recorded without it"
383
+ a.com_dr, a.com_scale = bool(meta.get("com_dr", False)), float(meta.get("com_scale", 1.0))
384
+ assert not a.residual or meta.get("residual", False), "--residual on a run recorded without it"
385
+ a.residual = bool(meta.get("residual", False))
386
+ assert "compiled" in meta, "a run recorded before the unification (no 'compiled' in meta.json) resumes on its own commit"
387
+ assert not (a.eager and meta["compiled"]), "--eager on a run recorded compiled"
388
+ a.eager = not bool(meta["compiled"])
389
+ a.ckpt_every = int(meta["ckpt_every"])
390
+ cfg = dict(meta["cfg"])
391
+ assert not a.overflow_done or meta.get("overflow_done", False), "--overflow-done on a run recorded without it"
392
+ a.overflow_done = bool(meta.get("overflow_done", False))
393
+ e = meta.get("easy") # PREREG_E1: the easy benchmark's settings come from the run's record too
394
+ assert not a.easy_every or e, "--easy-every on a run recorded without it"
395
+ if e:
396
+ a.easy_every, a.easy_dense_until, a.easy_sparse_every, a.easy_score = e["every"], e["dense_until"], e["sparse_every"], ",".join(e["which"])
397
+ a.easy_mpkpe_bar = e.get("mpkpe_bar")
398
+ assert a.npz, "--npz is required to train"
399
+ lm0 = G.LawMap()
400
+ m0 = G.Motion(a.npz, lm0)
401
+ if a.dry:
402
+ print(f"DRY ok: {m0.T} frames, {len(lm0.joints)} joints, cfg {json.dumps(cfg, default=str)}, score {which}, com_dr {a.com_dr}, residual {a.residual}, easy every {a.easy_every} "
403
+ f"(dense to {a.easy_dense_until}, then {a.easy_sparse_every}; {a.easy_score}), out {a.out}"
404
+ + (" (resume)" if a.resume else ""))
405
+ return
406
+ faulthandler.enable() # a fault in the driver still leaves the Python stack in the log
407
+ out = pathlib.Path(a.out)
408
+ out.mkdir(parents=True, exist_ok=True)
409
+ dev = "cpu" if a.cpu else "cuda"
410
+ dt = torch.float64 if a.cpu else torch.float32
411
+ sync = (lambda: None) if a.cpu else torch.cuda.synchronize
412
+ lm = G.LawMap(device=dev)
413
+ m = G.Motion(a.npz, lm, device=dev, dtype=dt)
414
+ from diffneusim.rl import g1_soft_grad as D
415
+ train_law = D.CpuJacLaw(B.ROBOT_BODIES, slots=a.H) if a.cpu else G.GpuLaw(a.n, B.ROBOT_BODIES, slots=a.H, tape=True, com_dr=a.com_dr)
416
+ eval_law = (lambda k: G.CpuLaw(B.ROBOT_BODIES)) if a.cpu else (lambda k: G.GpuLaw(k, B.ROBOT_BODIES, com_dr=a.com_dr))
417
+ ship = not a.nodr
418
+ dn_path = os.environ.get("DN_PATH", "fused") # the package's one switch: paper = what the paper's G1 runs did (eager + capture)
419
+ assert dn_path in ("fused", "paper"), f"DN_PATH={dn_path!r}: fused or paper"
420
+ if dn_path == "paper" and not a.resume:
421
+ assert not a.fused, "DN_PATH=paper with --fused"
422
+ a.eager, a.capture = True, a.capture or not a.cpu
423
+ assert not (a.fused and a.eager), "--fused (the old name of the default compiled path) with --eager"
424
+ print("[path] G1: " + ("paper-exact (eager + CUDA-graph capture, as the paper's runs; DN_PATH=paper)" if dn_path == "paper" and a.eager
425
+ else "eager (--eager or a CPU run)" if a.eager or a.cpu else "fused (compiled; 1.52x the paper's eager + capture route, not bitwise with it)"), flush=True)
426
+ from diffneusim.run_env import describe as env_line, run_env
427
+ renv = run_env() # recorded in meta.json (a resume: in its resumed_from entry)
428
+ print(env_line(renv), flush=True)
429
+ compiled = not a.eager and not a.cpu # the unification: one env, the compiled step IS BMTrack.step (session C, 11-11)
430
+ env = B.BMTrack(train_law, m, lm, a.n, ship=ship, device=dev, dtype=dt, seed=a.seed, differentiable=True, horizon=a.H, com_dr=a.com_dr,
431
+ com_scale=a.com_scale, residual=a.residual, overflow_done=a.overflow_done, compile=compiled)
432
+ if compiled:
433
+ from diffneusim.rl import g1_bm_fused as FU
434
+ compile_s = FU.warm_compile(env) if compiled else None # before SapoBM (which seeds the RNG) and before the clock
435
+ easy_which = [w.strip() for w in a.easy_score.split(",") if w.strip()]
436
+ assert easy_which and all(w in ("ema", "raw") for w in easy_which), a.easy_score
437
+ easy_cfg = (dict(every=a.easy_every, dense_until=a.easy_dense_until, sparse_every=a.easy_sparse_every, which=easy_which, n=EASY_N,
438
+ steps=EASY_STEPS, pass_rate=EASY_PASS, start_sigma=EASY_SIGMA, noise_seed=a.seed, mpkpe_bar=a.easy_mpkpe_bar)
439
+ if a.easy_every else None)
440
+ # PREREG_E1: the easy benchmark's env (never DR, whatever the run's) is built HERE, before SapoBM: BMTrack's constructor seeds the
441
+ # global RNG and draws its push timers, and SapoBM re-seeds it, so the training draws are those of a run without it
442
+ easy_env = (EasyTrack(eval_law(EASY_N), m, lm, EASY_N, ship=False, device=dev, dtype=dt, seed=a.seed, sampling="start", pushes=False,
443
+ obs_noise=False, reset_noise=False, sigma=EASY_SIGMA, noise_seed=a.seed, residual=a.residual) if easy_cfg else None)
444
+ agent = S.SapoBM(env, cfg, seed=a.seed)
445
+ probe = ActionPathProbe(env, a.residual)
446
+ active, first, resumed_from = 0.0, 1, None
447
+ if a.resume:
448
+ rs = torch.load(out / "resume.pt", weights_only=False)
449
+ assert rs["seed"] == a.seed and rs["ship"] == ship and int(rs["it"]) < a.iters, (rs["it"], a.iters)
450
+ agent._start_window() # allocates the static S and the start observation, then everything is overwritten
451
+ agent.restore_all(rs["state"])
452
+ active, first, resumed_from = float(rs["active_s"]), int(rs["it"]) + 1, int(rs["it"])
453
+ assert agent.it == resumed_from
454
+ # train.jsonl stays one history: the crashed segment's file is kept whole as train.jsonl.seg<k>, and the rows up to the resume point
455
+ # are carried into the new train.jsonl (a cut last line, the crash's mid-write, is never carried)
456
+ k = len(list(out.glob("train.jsonl.seg*")))
457
+ old = out / "train.jsonl"
458
+ seg = out / f"train.jsonl.seg{k}"
459
+ old.rename(seg)
460
+ tt = seg.read_text()
461
+ lines = [x for x in tt.splitlines() if x.strip()]
462
+ if tt and not tt.endswith("\n"):
463
+ lines = lines[:-1]
464
+ keep = [x for x in lines if json.loads(x)["it"] <= resumed_from]
465
+ assert [json.loads(x)["it"] for x in keep] == list(range(1, resumed_from + 1)), "train.jsonl lacks rows before the resume point"
466
+ old.write_text("".join(x + "\n" for x in keep))
467
+ meta = json.loads((out / "meta.json").read_text())
468
+ meta.setdefault("resumed_from", []).append(dict(it=resumed_from, active_s=active, segment_file=seg.name, iters=a.iters,
469
+ mode="captured" if a.capture else "eager", run_env=renv))
470
+ meta["iters"] = a.iters
471
+ assert bool(meta["compiled"]) == compiled, ("the resumed run's compile mode", meta["compiled"], compiled)
472
+ meta.setdefault("compile_s_resumes", []).append(compile_s)
473
+ if easy_cfg: # easy.jsonl as train.jsonl: the segment kept whole, its rows to the resume point carried
474
+ ef, eseg = out / "easy.jsonl", out / f"easy.jsonl.seg{k}"
475
+ et = ef.read_text() if ef.exists() else ""
476
+ if ef.exists():
477
+ ef.rename(eseg)
478
+ el = [x for x in et.splitlines() if x.strip()]
479
+ if et and not et.endswith("\n"):
480
+ el = el[:-1]
481
+ ef.write_text("".join(x + "\n" for x in el if json.loads(x)["it"] <= resumed_from))
482
+ else:
483
+ meta = dict(seed=a.seed, n=a.n, H=a.H, iters=a.iters, ckpt_every=a.ckpt_every, ship=ship, npz=a.npz, overflow_done=bool(a.overflow_done),
484
+ gpu="cpu" if a.cpu else torch.cuda.get_device_name(),
485
+ torch=torch.__version__, run_env=renv, cfg=cfg, A=agent.A.tolist(), score=which, mode="captured" if a.capture else "eager",
486
+ compiled=compiled, env="BMTrack", compile_s=compile_s, easy=easy_cfg,
487
+ inductor_deterministic=bool(env.compile_deterministic) if compiled else None, # as the warm compile saw it
488
+ com_dr=bool(a.com_dr), com_scale=float(a.com_scale), residual=bool(a.residual),
489
+ note=("CoM draw on (theirs, once per world); " if a.com_dr else "CoM draw absent (favours us); ")
490
+ + "self-contact substitute stricter than theirs; the same env and scorer as A2")
491
+ (out / "meta.json").write_text(json.dumps(meta, indent=1, default=str))
492
+ easy = None
493
+ if easy_cfg:
494
+ ep = out / "easy.jsonl"
495
+ assert a.resume or not (ep.exists() and ep.stat().st_size > 0), f"{ep} exists: a fresh run never appends to another's easy rows"
496
+ def crossing(w, it_, act_s): # PREREG_RG1: the crossing policy for sim2sim, outside the clock
497
+ torch.save(dict(snapshot=agent.checkpoint(), it=it_, active_s=act_s, which=w, seed=a.seed, ship=ship, residual=a.residual),
498
+ out / f"crossing_{w}.pt")
499
+ easy = Easy(easy_env, agent, easy_cfg["which"], easy_cfg["every"], easy_cfg["dense_until"], easy_cfg["sparse_every"], ep,
500
+ rows=[json.loads(x) for x in ep.read_text().splitlines() if x.strip()] if ep.exists() else (),
501
+ mpkpe_bar=easy_cfg.get("mpkpe_bar"), on_pass=crossing,
502
+ secondary=RG1_SECONDARY if easy_cfg.get("mpkpe_bar") is not None else None, secondary_every=RG1_SECONDARY_EVERY)
503
+ log = open(out / "train.jsonl", "a")
504
+ if a.resume and a.capture: # a resumed run captures before its first update (outside the clock)
505
+ assert not a.cpu, "capture needs CUDA"
506
+ probe.skip("captured resume: the first step runs inside the capture; the mode is the resumed run's own (meta.json)")
507
+ agent.capture(warmup=a.capture_warmup)
508
+ train_law.read_aflags() # the warm-ups' adjoint counts are not an update's
509
+ for it in range(first, a.iters + 1):
510
+ sync(); t0 = raw_now()
511
+ s = agent.iteration()
512
+ sync()
513
+ active += raw_now() - t0
514
+ if it == 1 and compile_s is not None:
515
+ s["compile_s"] = compile_s # the compiled env's warm compile, before the clock
516
+ if it == first: # the training-path check of the action mapping (a host read, outside the clock)
517
+ pr = dict(probe.read(), it=it)
518
+ print("TRAINING PATH action base: " + json.dumps(pr), flush=True)
519
+ (out / f"probe_it{it}.json").write_text(json.dumps(pr) + "\n") # its own file: train rows stay comparable across A/Bs
520
+ # the launch pipeline's instrument (the review 11-11): wall time at the end of this process's first update, outside the
521
+ # clock; fetch.py reports commit -> runner START -> FIRST_UPDATE from it. One line per process, the same format in every trainer
522
+ print(f"FIRST_UPDATE {time.strftime('%Y-%m-%dT%H:%M:%S%z')} it={it}", flush=True)
523
+ if not a.cpu: # the review, 11-11: the engine's flag bits for this update, from the env's per-world
524
+ # accumulators (overflow-as-done: BMTrack reads and zeroes the engine's word after every step): the OR of all bits, the
525
+ # worlds with kFlagOverflow (1, nefc > NR: the step not solved, its tape record invalid) and kFlagHandOverflow (256, an L2
526
+ # capacity exceeded), and the overflowed world-steps; one host read, outside the clock
527
+ s["eng_flags_or"], s["ovf_world_steps"] = env.read_overflow()
528
+ s["eng_overflow_worlds"], s["eng_hand_overflow_worlds"] = env.last_overflow_worlds
529
+ if a.overflow_done: # the trainer's count of the env's truncations (SapoBM's "overflow") is the env's own count
530
+ assert s["overflow"] == s["ovf_world_steps"], (f"update {it}: the trainer saw {s['overflow']} overflowed world-steps, "
531
+ f"the env counted {s['ovf_world_steps']}")
532
+ if not a.cpu: # the adjoint's overflow flags for this update (a host read, outside the clock)
533
+ s["aflag_bad"], s["aflag_or"] = train_law.read_aflags()
534
+ s["aflag_frac"] = check_aflags(s["aflag_bad"], a.n, a.H, a.aflag_max_frac)
535
+ if it == 1 and a.capture:
536
+ assert not a.cpu, "capture needs CUDA"
537
+ sync(); tc = raw_now()
538
+ agent.capture(warmup=a.capture_warmup) # outside the clock (setup), as InstantMimic excludes its compile and capture
539
+ sync(); s["capture_setup_s"] = raw_now() - tc
540
+ train_law.read_aflags() # the capture's warm-ups ran the adjoint: their counts are not an update's
541
+ if not a.cpu: # the trainer's peak device memory so far (a host query, outside the clock)
542
+ s["peak_alloc_gib"] = torch.cuda.max_memory_allocated() / 2 ** 30
543
+ row = dict(it=it, active_s=active, **{k: v for k, v in s.items() if isinstance(v, (int, float))})
544
+ if resumed_from is not None:
545
+ row["resumed_from"] = resumed_from
546
+ log.write(json.dumps(row) + "\n")
547
+ if it % 50 == 0: # durable every 50 updates (a fault loses at most 50 rows); outside the clock
548
+ log.flush(); os.fsync(log.fileno())
549
+ if it % a.ckpt_every == 0:
550
+ p = out / f"checkpoint_iter_{it}.pt"
551
+ torch.save(dict(snapshot=agent.checkpoint(), it=it, active_s=active, seed=a.seed, ship=ship), p)
552
+ tmp = out / "resume.pt.tmp" # the rolling resume state, replaced atomically (a crash mid-write keeps the old one)
553
+ torch.save(dict(state=agent.snapshot_all(bufs=False), it=it, active_s=active, seed=a.seed, ship=ship), tmp)
554
+ os.replace(tmp, out / "resume.pt")
555
+ log.flush(); os.fsync(log.fileno())
556
+ if easy is not None and easy.due(it): # PREREG_E1: outside the clock, after the update's records and checkpoint
557
+ easy.run(it, active)
558
+ log.close()
559
+ print(json.dumps(dict(iterations=a.iters, active_s=active, s_per_iter=active / max(1, a.iters - first + 1),
560
+ resumed_from=resumed_from)))
561
+ if a.no_eval:
562
+ return
563
+ del env, train_law
564
+ ckpts = [] # every segment's checkpoints (a resumed run scores the earlier ones too)
565
+ for q in out.glob("checkpoint_iter_*.pt"):
566
+ ck = torch.load(q, weights_only=False, map_location="cpu")
567
+ ckpts.append((int(ck["it"]), float(ck["active_s"]), q))
568
+ ckpts.sort()
569
+ score(agent, ckpts, m, lm, eval_law(a.eval_n), a.eval_n, ship, dev, dt, a.eval_seed or a.seed, which, out / "eval.jsonl", com_dr=a.com_dr, com_scale=a.com_scale,
570
+ residual=a.residual)
571
+ read_criteria(out)
572
+ print("A3 DONE")
573
+
574
+
575
+ if __name__ == "__main__":
576
+ main()