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,568 @@
1
+ """The E0 env on the new engine's training path (E0ENV14_PREREG.md): w3c's gpu_fullbody_vec_env, untouched, with its physics
2
+ swapped for the Step14 (feat/d16-14x train14.py), one control step per call. The env's own step() does everything else:
3
+ _act_to_excitation, its activation per substep (the reward's a_sum / 5), phase, reward, termination, resets / RSI, obs.
4
+
5
+ env = S.make_env("fullbody", cfg, seed, stochastic_init=True)
6
+ env14 = Env14(env, tree14, case_dir, H) # or install_from_env(env, H): E0_ENGINE14=1 is the flag, unset = the old engine
7
+
8
+ With grad enabled (the training rollout) the call is Step14.apply on a Window14 slot; SAPO's next initialize_trajectory (after its
9
+ backward) resets the window. Without grad (eval, render) it is Engine14.control_step, untaped (bitwise the taped forward). Until
10
+ the step 4 lifts Step14's muscle assert, lce / a / u go in detached and lce1 comes out detached (the actor's muscle gradient is 0).
11
+ """
12
+ import importlib.util
13
+ import os
14
+ import pathlib
15
+
16
+ import torch
17
+
18
+ # (3a) was: sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1] / "muscle_ref"))
19
+ from diffneusim.env.e0loop14 import rotm # noqa: E402
20
+ # the body (tools/d16_bodies/d16_body.py, D16_BODY=<tag>, unset the 14x): its quaternions' qpos addresses (the root's and the balls') and NV
21
+ # come from the header the engine compiles, so the chart below fits any body of the family (11-09, feat/d16-taskwalk: the 290)
22
+ # (3a) was: sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2] / "d16_bodies"))
23
+ from diffneusim.engine import d16_body as BODY # noqa: E402
24
+ QUATS, NV = tuple(BODY.QUATS), int(BODY.NV)
25
+ assert QUATS[0] == 3 and list(QUATS) == sorted(QUATS), QUATS
26
+
27
+
28
+ def old_to_law(q, qd):
29
+ """e0loop14's chart change, out of place (autograd-safe): the root and ball quaternions normalized, v[0:3] = R(q_root) qd[3:6]
30
+ (world), v[3:6] = qd[0:3] (body); the same operations as e0loop14.old_to_law, so the same values"""
31
+ # the process's body (D16_BODY at import) must be the state's: with another body's QUATS the slices still fill nq and the output is
32
+ # silently wrong (11-10: a 290 record read with D16_BODY unset normalized its left subtalar and mtp as a "quaternion")
33
+ assert q.shape[0] == BODY.NQ and qd.shape[0] == BODY.NV, (q.shape, qd.shape, BODY.NQ, BODY.NV, "D16_BODY must be the state's body")
34
+ nrm = lambda x: x / torch.linalg.norm(x, dim=0, keepdim=True) # noqa: E731
35
+ parts, k0 = [], 0 # the same slices as the 14x's literal form (3, 24, 32), for any body's QUATS
36
+ for k in QUATS:
37
+ parts += [q[k0:k], nrm(q[k:k + 4])]
38
+ k0 = k + 4
39
+ qn = torch.cat(parts + [q[k0:]], 0)
40
+ v = torch.cat([torch.einsum("ijn,jn->in", rotm(qn[3:7]), qd[3:6]), qd[0:3], qd[6:]], 0)
41
+ return qn, v
42
+
43
+
44
+ def law_to_old(q, v):
45
+ return torch.cat([v[3:6], torch.einsum("jin,jn->in", rotm(q[3:7]), v[0:3]), v[6:]], 0)
46
+
47
+ MUSCLE_GRAD = True # A later change lifted Step14's muscle-gradient assert (the step 4 wired, feat/d16-14x): lce / a / u keep their graph
48
+ RESET_FIX = True # in-step resets zero the warm start and keep the env's A0 (E0ENV14_PREREG.md, second amendment's section)
49
+ GLUE_COMPILE = os.environ.get("E0_ENV14_GLUE", "0") == "1" # M4b: the glue (charts + transposes) as one compiled function per direction
50
+ # E0_ENV14_F64=1 (2026-11-05, tools/e0_eval_f64): eval-only, glue off, no gradients. The engine runs in float64 and env14 keeps a
51
+ # float64 shadow of the physics state (q, v, warm, l_ce, a) across control steps; the env sees float32 copies for its observation,
52
+ # reward and terminations, as in training. A world the env resets enters the shadow from the env's (float32) state. Unset: unchanged.
53
+ F64 = False
54
+ # E0_ENV14_RESET32=1 (2026-11-07; feat/e0-eval-f64-root 8d06f5dd, the review): eval-only, with E0_ENV14_EQUIL14. The reset's fibre equilibrium runs
55
+ # on a float32 engine at KFIB (6), the policy's own launches (X14_EQUIL_SCHEDULE), whatever E0_ENV14_F64 and ENGINE14_KFIB set, so every arm of a
56
+ # replay starts each episode from one reset state. The paper's two root-reset f64 replays ran this (tools/e0_eval_f64/REPLAY_ROOT.md). Unset: the
57
+ # reset runs on the step's engine at its Newton count (under E0_ENV14_F64 the float64 engine; under ENGINE14_KFIB its count).
58
+ RESET32 = False
59
+ # E0_ENV14_ACT14=1 (2026-11-09, feat/d16-taskwalk step 2): the env's per-substep activation (its reward's a_sum / 5, the activation and
60
+ # metabolic terms) is the engine's own k_act14 (x14_engine_kernels.cuh: soft/muscle.h's muscle_activation, k_mus's first stage; the Mac gate
61
+ # tools/d16_taskwalk/test_act14.py: bitwise k_mus's per-substep a) with its VJP k_act14_vjp, instead of the old sim's activate (old_act 0).
62
+ # Unset: unchanged (the old filter, counted as old_act).
63
+ ACT14 = os.environ.get("E0_ENV14_ACT14", "0") == "1"
64
+ # E0_ENV14_KINLATCH=1 (2026-11-09, feat/d16-taskwalk step 3; the review's decision (a)): the mirror's strike latch reads each foot's contact in the
65
+ # D16 law (kin_contact14.FootTouch14: the floor pairs' geoms on calcn / toes within their margin, the engine's own active set, K0 / K1 against
66
+ # MuJoCo) through env._mirror_down, instead of the old engine's contact force above 1 N. Every control step asserts old_contact 0 and one latch
67
+ # read. Its gate's K2 FAIL and the diagnostic: tools/d16_taskwalk/PLAN.md 3a. Unset: unchanged.
68
+ KINLATCH = os.environ.get("E0_ENV14_KINLATCH", "0") == "1"
69
+ # E0_ENV14_NO_OLD=1 (the review, 11-09: the old engine at 0 calls): every control step asserts old_sim 0, the sum of every route into the old engine
70
+ # after the install (old_count.py), failing fast. Unset: counted only.
71
+ NO_OLD = os.environ.get("E0_ENV14_NO_OLD", "0") == "1"
72
+ # E0_ENV14_GROUND14=1 (2026-11-09, feat/d16-taskwalk step 4): the task-walk reset grounds its pose on the D16 law's foot geoms (the lowest
73
+ # just touches the plane, kin_contact14.FootTouch14.gap) instead of the old model's contact spheres. At the keyframe the old rule leaves the
74
+ # D16 foot 2.2 mm inside the floor on the 290 and the 14x. Flat ground only. Unset: unchanged.
75
+ GROUND14 = os.environ.get("E0_ENV14_GROUND14", "0") == "1"
76
+ # E0_ENV14_BACKEND=cpu (2026-11-09, feat/d16-taskwalk step 5): the Mac dry-run's engine, cpu14.CpuEngine14 (the GPU binding's own kernels
77
+ # through the fiber shim; E0_ENV14_CPU_LIB the built library), forward only, on the env's device (the CPU). Unset or "cuda": unchanged.
78
+ BACKEND = os.environ.get("E0_ENV14_BACKEND", "cuda")
79
+ assert BACKEND in ("cuda", "cpu"), f"E0_ENV14_BACKEND={BACKEND!r}: cuda or cpu"
80
+
81
+
82
+ class Act14(torch.autograd.Function):
83
+ """a_new = k_act14(u, a_prev) on the env's layout [NM, n]; the engine's layout is [n, NM] (transposed in and out)"""
84
+
85
+ @staticmethod
86
+ def forward(ctx, u, a_prev, ext, dt):
87
+ ut, at = u.detach().t().contiguous(), a_prev.detach().t().contiguous()
88
+ out = torch.empty_like(at)
89
+ ext.act([ut, at, out], dt)
90
+ ctx.save_for_backward(ut, at)
91
+ ctx.ext, ctx.dt = ext, dt
92
+ return out.t().contiguous()
93
+
94
+ @staticmethod
95
+ def backward(ctx, a_bar):
96
+ ut, at = ctx.saved_tensors
97
+ ub, ab = torch.empty_like(ut), torch.empty_like(at)
98
+ ctx.ext.act_vjp([ut, at, a_bar.t().contiguous(), ub, ab], ctx.dt)
99
+ return ub.t().contiguous(), ab.t().contiguous(), None, None
100
+
101
+
102
+ def equil14_default(glue):
103
+ """E0_ENV14_EQUIL14, P1's reset equilibrium on the 14x law (install_equil14): ON by default with the compiled glue
104
+ (E0_ENV14_GLUE=1, the E0 learning jobs' setting), off by default without it (eval14 runs the glue off), since the integration
105
+ commit after a3461d72 (the review, 2026-11-03). E0_ENV14_EQUIL14=0 turns it off; =1 asks for it. Under the default, a glue run
106
+ with DN_FIBER_INIT_VC=1 (the velocity-consistent start, not ported) or DN_FIBER_INIT_ITERS=0 (no equilibration)
107
+ fails at install_equil14's asserts: set E0_ENV14_EQUIL14=0 for it. So must every arm that means today's old-engine
108
+ equilibration (gate_equil14.py sets it itself)."""
109
+ v = os.environ.get("E0_ENV14_EQUIL14")
110
+ if v is None:
111
+ return bool(glue)
112
+ assert v in ("0", "1"), f"E0_ENV14_EQUIL14={v!r}: 0 or 1"
113
+ return v == "1"
114
+
115
+
116
+ def rew14_default(glue, env=None):
117
+ """E0_ENV14_REW14, the fused reward + observation node (tools/d16_fused_env): ON by default with the compiled glue
118
+ (E0_ENV14_GLUE=1, the E0 learning jobs' setting) and off by default without it (eval14 runs the glue off), since the
119
+ integration commit after 11e50a92 (the review, the design's approval, 2026-11-03). E0_ENV14_REW14=0 turns it off; =1 asks for it
120
+ (rew14_hook.install asserts the glue). A glue run in a configuration the node does not support (E0_M4C=1, mirror, taskwalk,
121
+ latent, OBS_AUG, YAW_FREE, ET_MODE, REF_SWITCH, dr_snap, musclepd) fails at install by the hook's asserts: set
122
+ E0_ENV14_REW14=0 for it. So must every timing or gate arm that means "without REW14"."""
123
+ v = os.environ.get("E0_ENV14_REW14")
124
+ if v is None:
125
+ if not glue:
126
+ return False
127
+ ok, why = rew14_supported(env) # unset: on wherever the node supports the configuration, off (and said so) elsewhere
128
+ if not ok:
129
+ print(f"[env14] E0_ENV14_REW14 off: the fused reward node does not support {why}", flush=True)
130
+ return ok
131
+ assert v in ("0", "1"), f"E0_ENV14_REW14={v!r}: 0 or 1"
132
+ return v == "1"
133
+
134
+
135
+ def rew14_supported(env):
136
+ """(ok, reason): the configurations rew14_hook.install accepts (its asserts, checked here without failing)"""
137
+ t = getattr(env, "imitation_task", None)
138
+ checks = [(t is not None and getattr(t, "IM_MIMIC", False) and getattr(env, "imitation", False), "a task other than mimic imitation"),
139
+ (getattr(env, "mirror", None) is None, "the mirror"), (getattr(env, "taskwalk", None) is None, "task walking"),
140
+ (getattr(env, "latent_task", None) is None and not getattr(env, "LATENT", False), "a latent task"),
141
+ (not getattr(env, "M4C", False), "E0_M4C"), (not getattr(env, "OBS_AUG", False), "OBS_AUG"),
142
+ (not getattr(env, "YAW_FREE", False), "YAW_FREE"), (not getattr(env, "ET_MODE", False), "ET_MODE"),
143
+ (not getattr(env, "REF_SWITCH", False), "REF_SWITCH"), (not getattr(env, "dr_snap", False), "dr_snap"),
144
+ (getattr(env, "musclepd", None) is None, "the MuscleVAE PD servo"),
145
+ (getattr(env, "_tw_fs", None) is None and getattr(env, "_tw_obs_h_ground", False) is False, "the task-walk observations"),
146
+ (t is None or (not getattr(t, "PHASE_OBS", False) and t.cond_obs(1) is None), "phase or conditional observations")]
147
+ for ok, why in checks:
148
+ if not ok:
149
+ return False, why
150
+ return True, ""
151
+
152
+
153
+ def glue_pre(q, qd, lce, a, u):
154
+ """the step's inputs to Step14's layout: the old chart to the law chart, world-major to lane-major (the eager path's ops)"""
155
+ qn, v = old_to_law(q, qd)
156
+ return qn.t().contiguous(), v.t().contiguous(), lce.t().contiguous(), a.t().contiguous(), u.t().contiguous()
157
+
158
+
159
+ def glue_post(q1, v1, l1, a1):
160
+ """Step14's outputs back: the law chart to the old chart, lane-major to world-major"""
161
+ q_old = q1.t()
162
+ return q_old.contiguous(), law_to_old(q_old, v1.t()).contiguous(), l1.t().contiguous(), a1.t().contiguous()
163
+
164
+
165
+ class Env14:
166
+ def __init__(self, env, tree14, case_dir, H):
167
+ # (3a) was: sys.path.insert(0, str(pathlib.Path(tree14) / "tools" / "d16_14x"))
168
+ from diffneusim.engine import engine14
169
+ self.env, self.n, self.H = env, env.num_envs, H
170
+ self.dt14 = float(engine14.DT) # the engine's substep (E0_ENV14_ACT14's op asserts the env's)
171
+ self.f64 = F64
172
+ fdt = torch.float32
173
+ self.dev = "cuda"
174
+ if BACKEND == "cpu": # the Mac dry-run (see BACKEND): no Step14 / Window14 (no adjoint), the env's device
175
+ # (3a) was: sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
176
+ from diffneusim.env import cpu14
177
+ self.dev = env.device
178
+ self.train14 = None
179
+ self.eng = cpu14.CpuEngine14(self.n, fdt, case_dir, os.environ["E0_ENV14_CPU_LIB"])
180
+ env.sim_on_cpu = True # the env equilibrates its resets where the simulation runs (gpu_fullbody_vec_env._reset_envs)
181
+ else:
182
+ from diffneusim.engine import soft14
183
+ from diffneusim.engine import step14 as train14 # (3a fix) tools/d16_14x/train14.py, not the imitation driver
184
+ self.train14 = train14
185
+ self.eng = engine14.Engine14(self.n, fdt, case_dir)
186
+ # E0_ENV14_RESET32=1 (see RESET32): the reset's fibre equilibrium on a float32 engine at KFIB, the policy's own reset, whatever
187
+ # E0_ENV14_F64 and ENGINE14_KFIB set; each world's f64 shadow enters from that f32 entry. Unset: the reset follows self.eng.
188
+ self.eng_equil = self.eng
189
+ self.win = train14.Window14(self.n, H) if BACKEND == "cuda" else None
190
+ self.chart = train14.Chart14(soft14.Soft14().L) if BACKEND == "cuda" else None
191
+ self.warm = torch.zeros(self.n, NV, dtype=fdt, device=self.dev)
192
+ self.sh, self.sh_last = None, None # E0_ENV14_F64's shadow and what it handed the env
193
+ self.dirty = torch.ones(self.n, dtype=torch.bool, device=self.dev) # E0_ENV14_F64: worlds the env (re)set since the last step
194
+ self.win_used = False
195
+ self.count = dict(step14=0, control_step=0, old_sim=0, win_reset=0)
196
+ self.cap = {}
197
+ self.k = 0
198
+ self.out = None
199
+ self.glue = GLUE_COMPILE
200
+ if self.glue:
201
+ assert MUSCLE_GRAD
202
+ # fused, never CUDA-graphed: under m4a's cudagraph trees the glue's inputs alternate between graph-managed outputs and
203
+ # eager tensors (resets), so the tree re-recorded it ("cudagraph managed tensor data pointer changed", a ~30 s stall
204
+ # per occurrence, 06:16), and every graphed glue call deepens BPTT's pending path by one node
205
+ opts = {"triton.cudagraphs": False}
206
+ self.pre = torch.compile(glue_pre, dynamic=False, options=opts)
207
+ self.post = torch.compile(glue_post, dynamic=False, options=opts)
208
+ self.old_sim = env.sim
209
+ # the calls that still reach the old engine (activation, contact readouts, old equilibria): counted, not changed (old_count.py)
210
+ _spec = importlib.util.spec_from_file_location("old_count", pathlib.Path(__file__).resolve().parent / "old_count.py")
211
+ _oc = importlib.util.module_from_spec(_spec)
212
+ _spec.loader.exec_module(_oc)
213
+ self.oldc = _oc.install(env, self)
214
+ if ACT14:
215
+ assert os.environ.get("E0_REW14_SKIP_ENV_ACT", "0") != "1", "E0_ENV14_ACT14 with E0_REW14_SKIP_ENV_ACT: one owner of the activation"
216
+ assert env.musclepd is None, "E0_ENV14_ACT14: the env's MuscleVAE PD servo sets A itself"
217
+ self.count["act14"] = 0
218
+
219
+ def act14(u, a, dt):
220
+ assert abs(float(dt) - self.dt14) < 1e-15, (dt, self.dt14)
221
+ self.count["act14"] += 1
222
+ return Act14.apply(u, a, self.eng.ext, self.dt14)
223
+ env._activation = act14
224
+ self.foot = None
225
+ if KINLATCH or GROUND14:
226
+ import json
227
+ # (3a) was: sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
228
+ from diffneusim.env import kin_contact14
229
+ assert not getattr(env, "_tw_slopes_live", False), "E0_ENV14_KINLATCH / GROUND14: flat ground only (the floor plane z = 0)"
230
+ law = json.load(open(BODY.LAW))
231
+ assert pathlib.Path(env.model).name == law["source"]["dnmodel"], ("the env's body is not the law's", env.model, law["source"])
232
+ self.foot = kin_contact14.FootTouch14(BODY.LAW, env._monitor, env.device, torch.float32)
233
+ if KINLATCH:
234
+ assert getattr(env, "mirror", None) is not None, "E0_ENV14_KINLATCH: the latch is the mirror's (DN_MIRROR_SYM=1)"
235
+ assert getattr(env, "_tw_fs", None) is None, "E0_ENV14_KINLATCH: the footstep plan reads the contact force itself"
236
+ def _latch_poses(): # TW1 K2 (train_tw14 --tw1-k2): the reward's FK of this q, hoisted before the latch, detached
237
+ fk = getattr(env, "_tw_fk_pre", None)
238
+ if fk is None:
239
+ return None
240
+ return ({b: fk[0][b].detach() for b in self.foot.bodies}, {b: fk[1][b].detach() for b in self.foot.bodies})
241
+ env._mirror_down = lambda: self.foot.touch(env.q.detach(), _latch_poses())
242
+ # TASKWALK_FALL_NONFOOT=1 (opt-in; 11-13, the review, the m118: the running line ends KNEELING on the femur / tibia floor pairs,
243
+ # the root above FALL_ROOT_H): a fall when any NON-foot floor pair of the D16 law is within its margin, the engine's own contact set.
244
+ # The reward's fall test calls env._tw_nonfoot_term(q) (a function, no carried state). Its bodies join the reward's FK set only with
245
+ # the knob on, so the hoisted FK of TW1 K2 covers them (no second FK there); knob off = no change at all.
246
+ self.nonfoot = None
247
+ if os.environ.get("TASKWALK_FALL_NONFOOT", "0") != "0":
248
+ assert os.environ["TASKWALK_FALL_NONFOOT"] == "1", os.environ["TASKWALK_FALL_NONFOOT"]
249
+ assert KINLATCH, "TASKWALK_FALL_NONFOOT reads the D16 law's contact set beside the latch: set E0_ENV14_KINLATCH=1"
250
+ self.nonfoot = kin_contact14.FootTouch14(BODY.LAW, env._monitor, env.device, torch.float32, geoms=kin_contact14.other_geoms)
251
+ env._tw_bodies = sorted(set(env._tw_bodies) | set(self.nonfoot.bodies))
252
+
253
+ def _nonfoot_poses():
254
+ fk = getattr(env, "_tw_fk_pre", None)
255
+ if fk is None:
256
+ return None
257
+ return ({b: fk[0][b].detach() for b in self.nonfoot.bodies}, {b: fk[1][b].detach() for b in self.nonfoot.bodies})
258
+ env._tw_nonfoot_term = lambda: self.nonfoot.any_down(env.q.detach(), _nonfoot_poses())
259
+ print(f"[env14] TASKWALK_FALL_NONFOOT: a fall on any of {len(self.nonfoot.geoms['o'])} non-foot floor pairs within the margin "
260
+ f"{self.nonfoot.margin} m ({sorted({g['body'] for g in self.nonfoot.geoms['o']})})", flush=True)
261
+ # TASKWALK_LIMIT_TORQUE_STOP=1 (11-14): the reward's limit-torque term adds the solver's stop, from this law's limit rows
262
+ if os.environ.get("TASKWALK_LIMIT_TORQUE_STOP", "0") != "0":
263
+ env._tw_law_path = str(BODY.LAW)
264
+ if GROUND14:
265
+ assert env.taskwalk is not None and (not env._tw_init_ref or os.environ.get("D16_TW_RESET") in ("ks14t_clip", "run_clip", "run_clip_1646",
266
+ "pose3_scone", "diag_states", "x016run_states", "myoassist_clip", "s11_clip")), \
267
+ "E0_ENV14_GROUND14: the task-walk reset (the keyframe, or a declared D16_TW_RESET=ks14t_clip / run_clip / run_clip_1646 (train_tw14.RUN_CLIPS) / myoassist_clip / s11_clip (train_tw14.RUN_CLIPS) / pose3_scone (train_tw14.POSE_SETS) / x016run_states (train_tw14.STATE_LISTS) / diag_states (train_tw14, eval only): _tw_ground_pose runs after the RSI draw)"
268
+ self.count["ground14"] = 0
269
+
270
+ def ground14(q0, env_ids):
271
+ with torch.no_grad():
272
+ q0 = q0.clone()
273
+ # the env's own joint-limit clamp (_reset_envs applies it AFTER the grounding) first, so the grounded pose is the final
274
+ # one: the clamp is idempotent and leaves the root's translation alone. Without it the dry-run found the knees (keyframe
275
+ # at their limit, the noise past it) clamped after the grounding, the D16 foot up to 0.7 mm in the floor
276
+ q0[env._lim_qadr] = torch.clamp(q0[env._lim_qadr], env._lim_lo.to(q0.dtype), env._lim_hi.to(q0.dtype))
277
+ gap = self.foot.gap(q0)
278
+ ez = torch.zeros(3, q0.shape[1], dtype=q0.dtype, device=q0.device)
279
+ ez[2] = gap.to(q0.dtype)
280
+ q0[:3] -= env._tw_root_from_world.to(q0.dtype) @ ez # the old rule's map from a world shift to the root's qpos
281
+ self.count["ground14"] += 1
282
+ return q0
283
+ env._tw_ground_pose = ground14
284
+ orig_ate = env._act_to_excitation
285
+
286
+ def act2u(x):
287
+ u = orig_ate(x)
288
+ self.cap["u"] = u
289
+ return u
290
+ env._act_to_excitation = act2u
291
+ # resets: step() resets its done envs through _reset_envs (never through reset, which also calls it). For those ids the
292
+ # contact warm start is zeroed (MuJoCo's mj_resetData) and the reset mask keeps the env's A0 over k_mus's a1 (the old
293
+ # env's graph cut). reset_fix False is the gate's positive control: the pre-fix hook on reset only
294
+ self.reset_fix = RESET_FIX
295
+ self.reset_mask = torch.zeros(self.n, dtype=torch.bool, device=self.dev)
296
+ orig_reset_envs = env._reset_envs
297
+
298
+ def reset_envs(env_ids=None):
299
+ out = orig_reset_envs(env_ids)
300
+ if self.reset_fix:
301
+ with torch.no_grad():
302
+ if env_ids is None:
303
+ self.warm.zero_()
304
+ self.reset_mask.fill_(True)
305
+ else:
306
+ self.warm.index_fill_(0, env_ids, 0.0)
307
+ self.reset_mask.index_fill_(0, env_ids, True)
308
+ return out
309
+ env._reset_envs = reset_envs
310
+ orig_reset = env.reset
311
+
312
+ def reset(env_ids=None, *x, **kw):
313
+ out = orig_reset(env_ids, *x, **kw)
314
+ if not self.reset_fix:
315
+ with torch.no_grad():
316
+ if env_ids is None:
317
+ self.warm.zero_()
318
+ else:
319
+ self.warm[env_ids] = 0.0
320
+ return out
321
+ env.reset = reset
322
+ orig_init = env.initialize_trajectory
323
+
324
+ def initialize_trajectory(*x, **kw):
325
+ if self.win_used: # the previous window's backward has run (SAPO's order)
326
+ self.win.reset()
327
+ self.win_used = False
328
+ self.count["win_reset"] += 1
329
+ return orig_init(*x, **kw)
330
+ env.initialize_trajectory = initialize_trajectory
331
+ orig_step = env.step
332
+
333
+ def step(actions):
334
+ assert self.k == 0, f"env14: a control step starts at substep 0, found k = {self.k}" # (P2 (iv): k is static per step)
335
+ self.reset_mask.zero_()
336
+ n_act = self.count.get("act14", 0)
337
+ n_latch = self.foot.n_calls if self.foot is not None else 0
338
+ out = orig_step(actions)
339
+ if KINLATCH:
340
+ assert self.count.get("old_contact", 0) == 0, f"E0_ENV14_KINLATCH: the old contact force ran ({self.count.get('old_contact')} calls)"
341
+ assert self.foot.n_calls - n_latch == 1, ("E0_ENV14_KINLATCH: the latch did not read the D16 contact once", self.foot.n_calls - n_latch)
342
+ if NO_OLD:
343
+ assert self.count.get("old_sim", 0) == 0, f"E0_ENV14_NO_OLD: the old engine ran after the install: {dict(self.oldc.names)}"
344
+ if ACT14: # the review (11-09): the switch proved at run time, every control step, failing fast (not logged)
345
+ assert self.count.get("old_act", 0) == 0, f"E0_ENV14_ACT14: the old activation ran ({self.count.get('old_act')} calls)"
346
+ assert self.count["act14"] - n_act == env.SUBSTEPS, ("E0_ENV14_ACT14: the engine's op did not run once per substep",
347
+ self.count["act14"] - n_act, env.SUBSTEPS)
348
+ if self.a1 is not None: # the next step's a is the engine's a1 (its gradient chain); the reward's a_sum used the env's op
349
+ # the mask's clone: where saves its condition for the backward, and the next step rewrites reset_mask in place.
350
+ # env.a detached: its reset columns are constants, and its other columns (the env op's a, masked out) would only
351
+ # send exact zeros back through the env's activation op (a dead backward, 1.5 ms per control step at 4,096)
352
+ env.a = (torch.where(self.reset_mask[None, :].clone(), env.a.detach(), self.a1).contiguous() if self.reset_fix
353
+ else self.a1)
354
+ return out
355
+ env.step = step
356
+ self.a1 = None
357
+ outer = self
358
+
359
+ class Sim:
360
+ def step(self, q, qd, tau=None, lce=None, A=None, z=None, dt=None):
361
+ if outer.k == 0:
362
+ outer.out = outer._control_step(z)
363
+ outer.k = (outer.k + 1) % env.SUBSTEPS
364
+ return outer.out
365
+
366
+ def __getattr__(self, name):
367
+ return outer.oldc.forward("sim", outer.old_sim, name)
368
+ env.sim = Sim()
369
+
370
+ def assert_guards(self, where, latch_reads=None):
371
+ """The step wrapper's switch checks (E0_ENV14_KINLATCH / NO_OLD / ACT14) for a loop that calls env._step_a directly: SapoWindow, the
372
+ captured path, where the wrapper above never runs (11-13, the review: heel mode's old-engine GRF trained 8 epochs unseen there,
373
+ caught only by a gate's end-of-run count). Python counters only: no device read. latch_reads, when given, is the number of latch
374
+ reads the window must have made (one per eager step, none in a replay)."""
375
+ if KINLATCH:
376
+ assert self.count.get("old_contact", 0) == 0, f"E0_ENV14_KINLATCH ({where}): the old contact force ran ({self.count.get('old_contact')} calls)"
377
+ if latch_reads is not None:
378
+ assert latch_reads[0] == latch_reads[1], f"E0_ENV14_KINLATCH ({where}): the latch read the D16 contact {latch_reads[0]} times, not {latch_reads[1]}"
379
+ if NO_OLD:
380
+ assert self.count.get("old_sim", 0) == 0, f"E0_ENV14_NO_OLD ({where}): the old engine ran after the install: {dict(self.oldc.names)}"
381
+ if ACT14:
382
+ assert self.count.get("old_act", 0) == 0, f"E0_ENV14_ACT14 ({where}): the old activation ran ({self.count.get('old_act')} calls)"
383
+
384
+ def _control_step(self, z):
385
+ if self.glue:
386
+ return self._control_step_glue(z)
387
+ env = self.env
388
+ qn, v = old_to_law(env.q, env.qd)
389
+ qw, vw = qn.t().contiguous(), v.t().contiguous()
390
+ if MUSCLE_GRAD:
391
+ lw, aw, uw = (x.t().contiguous() for x in (env.lce, env.a, self.cap["u"]))
392
+ else:
393
+ lw, aw, uw = (x.detach().t().contiguous() for x in (env.lce, env.a, self.cap["u"]))
394
+ if torch.is_grad_enabled():
395
+ q1, v1, l1, a1, w1 = self.train14.Step14.apply(qw, vw, lw, aw, uw, self.warm, self.eng, self.win, self.chart)
396
+ self.win_used = True
397
+ self.count["step14"] += 1
398
+ else:
399
+ o = self.eng.control_step(qw, vw, self.warm, lw, aw, uw)
400
+ q1, v1, l1, w1 = (o[k].clone() for k in ("qpos", "qvel", "lce", "warm"))
401
+ self.count["control_step"] += 1
402
+ self.warm.copy_(w1.detach()) # in place: the one env14 state that crosses control steps (CAPTURE_PLAN.md P2 (iv))
403
+ a1o = a1 if torch.is_grad_enabled() else o["a"].clone()
404
+ self.a1 = (a1o.t() if MUSCLE_GRAD else a1o.detach().t()).contiguous()
405
+ q_old = q1.t()
406
+ qd_old = law_to_old(q_old, v1.t())
407
+ l_old = l1.t() if MUSCLE_GRAD else l1.detach().t()
408
+ return q_old.contiguous(), qd_old.contiguous(), l_old.contiguous(), z
409
+
410
+
411
+ def _control_step_f64(self, z):
412
+ """E0_ENV14_F64: the control step on the float64 engine from the float64 shadow. A world the env did not reset must still
413
+ hold exactly the float32 copy this path handed it (asserted), so no other writer of the env's state goes unseen."""
414
+ assert not torch.is_grad_enabled(), "E0_ENV14_F64 replays without gradients (eval14)"
415
+ env = self.env
416
+ if self.sh_last is not None:
417
+ keep = ~self.dirty
418
+ for name, x, last in zip(("q", "qd", "lce", "a"), (env.q, env.qd, env.lce, env.a), self.sh_last):
419
+ assert torch.equal(x[:, keep], last[:, keep]), f"E0_ENV14_F64: the env changed a non-reset world's {name}"
420
+ qn, v = old_to_law(env.q.double(), env.qd.double())
421
+ cur = dict(q=qn, v=v, l=env.lce.double(), a=env.a.double())
422
+ if self.sh is None:
423
+ self.sh = {k: x.clone() for k, x in cur.items()}
424
+ else:
425
+ d = self.dirty
426
+ for k in self.sh:
427
+ self.sh[k][:, d] = cur[k][:, d]
428
+ self.dirty.zero_()
429
+ o = self.eng.control_step(self.sh["q"].t().contiguous(), self.sh["v"].t().contiguous(), self.warm,
430
+ self.sh["l"].t().contiguous(), self.sh["a"].t().contiguous(), self.cap["u"].double().t().contiguous())
431
+ q1, v1, l1, w1, a1 = (o[k].clone() for k in ("qpos", "qvel", "lce", "warm", "a"))
432
+ self.count["control_step"] += 1
433
+ self.warm.copy_(w1)
434
+ self.sh = dict(q=q1.t().contiguous(), v=v1.t().contiguous(), l=l1.t().contiguous(), a=a1.t().contiguous())
435
+ q_old = self.sh["q"].float().contiguous()
436
+ qd_old = law_to_old(self.sh["q"], self.sh["v"]).float().contiguous()
437
+ l_old = self.sh["l"].float().contiguous()
438
+ self.a1 = self.sh["a"].float().contiguous()
439
+ self.sh_last = (q_old, qd_old, l_old, self.a1)
440
+ return q_old, qd_old, l_old, z
441
+
442
+ def _control_step_glue(self, z):
443
+ """M4b: _control_step with the glue compiled (E0_ENV14_GLUE=1); the same operations, fused, so roundoff (gated)"""
444
+ env = self.env
445
+ qw, vw, lw, aw, uw = self.pre(env.q, env.qd, env.lce, env.a, self.cap["u"])
446
+ if torch.is_grad_enabled():
447
+ q1, v1, l1, a1, w1 = self.train14.Step14.apply(qw, vw, lw, aw, uw, self.warm, self.eng, self.win, self.chart)
448
+ self.win_used = True
449
+ self.count["step14"] += 1
450
+ else:
451
+ o = self.eng.control_step(qw, vw, self.warm, lw, aw, uw)
452
+ q1, v1, l1, w1, a1 = (o[k].clone() for k in ("qpos", "qvel", "lce", "warm", "a"))
453
+ self.count["control_step"] += 1
454
+ self.warm.copy_(w1.detach()) # in place: the one env14 state that crosses control steps (CAPTURE_PLAN.md P2 (iv))
455
+ q_old, qd_old, l_old, self.a1 = self.post(q1, v1, l1, a1)
456
+ return q_old, qd_old, l_old, z
457
+
458
+
459
+ def install_equil14(env, e14):
460
+ """P1 (tools/e0speed/CAPTURE_PLAN.md), E0_ENV14_EQUIL14=1: the reset's fibre equilibrium on the 14x law (Engine14.equil_lce,
461
+ one masked kernel) in place of the old engine's mtu_gpu.equilibrate_fibers, for this env only. The same iteration (l_ce_prev
462
+ <- l_ce at fixed q0 and a0) and the same round count (DN_FIBER_INIT_ITERS, default 8), on the stage's own fibre solve."""
463
+ old, eng = env._myoleg_gpu, e14.eng_equil
464
+ # the case's muscles are the env's model's, in the env's order: lce, a and u cross this boundary by index
465
+ lo = torch.as_tensor(eng.case["lopt"], dtype=torch.float64).cpu()
466
+ dl = float((lo - env.l_opt.double().cpu()).abs().max())
467
+ assert lo.numel() == env.l_opt.numel() and dl < 1e-6, f"the case's l_opt is not the model's: max |d| {dl}"
468
+ print(f"[env14] the case's l_opt = the model's, in order: {lo.numel()} muscles, max |d| {dl:.2e} m", flush=True)
469
+ outer = int(os.environ.get("DN_FIBER_INIT_ITERS", "8"))
470
+ assert outer >= 1, "E0_ENV14_EQUIL14 with DN_FIBER_INIT_ITERS=0 (no equilibration): unset the flag instead"
471
+ e14.count.setdefault("equil14", 0)
472
+
473
+ _mc_tab = {}
474
+
475
+ def _millard_reset_counter(P):
476
+ """(11-17 23:4x, the review: the l_ce-move assert WITHDRAWN as mis-specified; the commit message holds the table) three numbers
477
+ of a Millard f64 reset as a device tensor [3] (no host read): the compliant (world, muscle) pairs whose one more f64 polish round
478
+ moves l_ce by more than 1e-3 l_opt; the largest F_T / F_max among those pairs (at the schedule's end); the largest
479
+ |F_T(after the extra round) - F_T(at the schedule's end)| / F_max over ALL compliant pairs. F_T at a round's end = the fibre side at
480
+ that round's own velocity (millard_curves_torch.mtu_forces: F_max cos(phi) (A f_L f_V + f_PE + beta v0), the engine's residual at
481
+ its solved state)."""
482
+ if not _mc_tab:
483
+ from diffneusim.rl import millard_curves_torch as _mct
484
+ names = [m_["name"] for m_ in env._monitor.jm["muscles"]]
485
+ _mc_tab["p"] = _mct.case_table(os.environ["E0_MUSCLE_CASE"], names, P["l_end"].device, torch.float64)
486
+ _mc_tab["f"] = _mct.mtu_forces
487
+ p, f = _mc_tab["p"], _mc_tab["f"]
488
+ dt_ = P["dt"]
489
+ le, lm, lp, a_ = P["l_end"].t(), P["l_more"].t(), P["l_prev"].t(), P["a"].t() # (n_mus, n_env), as mtu_forces takes them
490
+ fe = f(le, (le - lp) / dt_, a_, p)[0] / p["F_max"]
491
+ fm = f(lm, (lm - le) / dt_, a_, p)[0] / p["F_max"]
492
+ comp = ~p["rigid"].expand_as(fe)
493
+ mv = (lm - le).abs() / p["l_opt"]
494
+ big = comp & (mv > 1e-3)
495
+ zero = torch.zeros((), dtype=fe.dtype, device=fe.device)
496
+ return torch.stack([big.sum().to(fe.dtype), torch.where(big, fe.abs(), zero).max(), torch.where(comp, (fm - fe).abs(), zero).max()])
497
+
498
+ def equilibrate_fibers(q0, lce0, a0, dt, model_path=None, qd=None, iters=None):
499
+ assert qd is None, "E0_ENV14_EQUIL14: DN_FIBER_INIT_VC (the velocity-consistent start) is not ported"
500
+ n = q0.shape[1]
501
+ with torch.no_grad():
502
+ qn, _ = old_to_law(q0, torch.zeros(env.qd.shape[0], n, dtype=q0.dtype, device=q0.device))
503
+ qt, at, msk = qn.t().contiguous().to(eng.dt), a0.t().contiguous().to(eng.dt), torch.ones(n, dtype=torch.bool, device=q0.device) # the engine's dtype (main's E0_ENV14_F64)
504
+ out = eng.equil_lce(qt, lce0.t().contiguous().to(eng.dt), at, msk, outer=outer if iters is None else int(iters))
505
+ mc = None
506
+ if getattr(eng, "millard_polish", None) is not None: # (11-17 23:4x, the review) the f64 Millard reset's LOGGED counter (no assert)
507
+ mc = _millard_reset_counter(eng.millard_polish)
508
+ eng.millard_polish = None
509
+ acc = getattr(e14, "millard_counter", None)
510
+ e14.millard_counter = mc if acc is None else torch.stack([acc[0] + mc[0], torch.maximum(acc[1], mc[1]), torch.maximum(acc[2], mc[2])])
511
+ e14.millard_counter_calls = getattr(e14, "millard_counter_calls", 0) + 1
512
+ if e14.millard_counter_calls % 256 == 0: # one host read every 256 reset calls: the running totals since the first reset
513
+ c = e14.millard_counter.tolist()
514
+ print(f"[env14] Millard reset counter after {e14.millard_counter_calls} reset calls: pairs whose one more f64 polish round moves "
515
+ f"> 1e-3 l_opt {int(c[0])}, max F_T / F_max among them {c[1]:.3e}; max |dF_T| / F_max over all compliant pairs {c[2]:.3e} (logged)",
516
+ flush=True)
517
+ if e14.count["equil14"] == 0: # the trainer's own record of the reset it runs: the law, the launches, and the fibres against this model's l_opt
518
+ r = out / env.l_opt.view(1, -1)
519
+ with torch.no_grad(): # the residual: one further fibre-solve round at the step's DT, |its move| / l_opt (no state written)
520
+ res = (eng.equil_residual(qt, out, at, msk) / env.l_opt.view(1, -1)).flatten()
521
+ print(f"[env14] first reset: law {'millard' if eng.millard else 'geyer'}, launches (rounds, dt) {eng.equil_log}, {n} worlds, a0 {float(a0.mean()):.4f}, "
522
+ f"l_ce / l_opt min {float(r.min()):.3f} p1 {float(r.quantile(0.01)):.3f} median {float(r.median()):.3f} p99 {float(r.quantile(0.99)):.3f} max {float(r.max()):.3f}; "
523
+ f"residual (one more round at DT, |d l_ce| / l_opt) median {float(res.median()):.2e} p99 {float(res.quantile(0.99)):.2e} max {float(res.max()):.2e}"
524
+ + ("" if mc is None else "; Millard f64 reset, one more f64 polish round (logged, no assert): pairs moving > 1e-3 l_opt "
525
+ f"{int(mc[0])}, max F_T / F_max among them {float(mc[1]):.3e}, max |dF_T| / F_max over all compliant pairs {float(mc[2]):.3e}"),
526
+ flush=True)
527
+ e14.count["equil14"] += 1
528
+ return out.t().contiguous().to(lce0.dtype) # the env keeps its own dtype (a no-op unless E0_ENV14_F64)
529
+
530
+ class MtuProxy: # the env's mtu_gpu handle with equilibrate_fibers replaced; everything else is the module's
531
+ def __getattr__(self, k):
532
+ return getattr(old, k)
533
+ proxy = MtuProxy()
534
+ proxy.equilibrate_fibers = equilibrate_fibers
535
+ env._myoleg_gpu = proxy
536
+ pending = getattr(env, "_fibres_pending", False) # (3a) the construction reset kept its seed fibres (no old engine)
537
+ if eng.millard or eng.equil_schedule is not None or pending:
538
+ # (X14_EQUIL_SCHEDULE, the Geyer-root arm: the construction reset ran the old engine's 8 rounds at DT, not the schedule, so it is redone too.)
539
+ # The construction reset (GpuFullBodyVecEnv.__init__'s self.reset(), before the trainer installs env14) equilibrated every
540
+ # world's fibres on the old engine, i.e. the Geyer law, and SapoVec.train does not reset at its start. On a Millard case each
541
+ # world's first episode would start from the wrong law's fibres, so redo that equilibrium here on the case's law, at the same
542
+ # (q, a) from the reset's seed l_opt: no RNG draw, so poses and the random stream are unchanged. A Geyer case skips this
543
+ # (its construction reset is already its own law). The review, 11-06, decision B.
544
+ assert env.musclepd is None, "the construction re-equilibration does not set musclepd's _pd_lce_prev"
545
+ seed = env.l_opt.view(-1, 1).repeat(1, env.num_envs).contiguous()
546
+ lce = equilibrate_fibers(env.q, seed, env.a, env.dt, env.model)
547
+ assert lce.shape == env.lce.shape and lce.dtype == env.lce.dtype and bool(torch.isfinite(lce).all()), (lce.shape, lce.dtype)
548
+ env.lce = lce
549
+ env._fibres_pending = False
550
+
551
+
552
+ def install_from_env(env, H, tree14=None, case_dir=None):
553
+ """the flag: E0_ENGINE14=1 swaps the physics; unset leaves the old engine (returns None)"""
554
+ if os.environ.get("E0_ENGINE14", "0") != "1":
555
+ return None
556
+ tree14 = tree14 or os.environ["E0_TREE14"]
557
+ case_dir = case_dir or os.environ["E0_MUSCLE_CASE"]
558
+ e14 = Env14(env, tree14, case_dir, H)
559
+ e14.equil_on = equil14_default(e14.glue) # P1 (equil14_default: on with the glue)
560
+ if e14.equil_on:
561
+ install_equil14(env, e14)
562
+ assert not getattr(env, "_fibres_pending", False), "the construction reset's fibres are unequilibrated: E0_ENV14_EQUIL14 must be on"
563
+ e14.rew14_on = rew14_default(e14.glue, env)
564
+ if e14.rew14_on: # the fused reward + obs node (tools/d16_fused_env/rew14_hook.py)
565
+ # (3a) was: sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2] / "d16_fused_env"))
566
+ from diffneusim.env import rew14_hook
567
+ rew14_hook.install(env, e14, H)
568
+ return e14