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,80 @@
1
+ """The body a gate tool runs on (2026-11-06; PORT_DESIGN.md section 5, "Gates", and 7.6). D16_BODY=<tag> names core/soft/gpu/generated/body_<tag>.cuh;
2
+ it is required (unset, the run is refused with the shipped bodies' builds named). The values are read from that header, the file the kernels compile, so a tool cannot hold its
3
+ own copy of them: 7.6's literal `(3, 24, 32)` normalizes quaternions at the 14x's addresses and silently corrupts another body's hinges.
4
+ TAG, V (every D16_BODY_ value), QUATS (qpos addresses of the root's and the balls' quaternions), LAW (the law JSON), MODEL (the .dnmodel, for the
5
+ CPU muscle references), fused() (the fused .dnmodel they load), build_flags() (nvcc / c++); X14 (the generated x14 header the body compiles), NLIM
6
+ (its limits, asserted equal to the law's), NLW (its limit mask words: a phase B header's, else None), PHASE_B (NV > 64: build_flags() then
7
+ carries -DD16_NV_GT64) and SPLIT_WORDS (a phase B body's split storage words, the record's L_H; else None).
8
+ A tool picks up its sizes at import, so the whole process runs one body."""
9
+ import json
10
+ import os
11
+ import re
12
+
13
+ from diffneusim._paths import ROOT as ROOT # (3a) the repo root
14
+ GPU = ROOT / "core" / "soft" / "gpu"
15
+ TAG = os.environ.get("D16_BODY", "")
16
+
17
+
18
+ def _read(path):
19
+ return {k: int(v) for k, v in re.findall(r"^#define D16_BODY_(\w+) (\d+)\s*$", path.read_text(), re.M)}
20
+
21
+
22
+ def _no_body():
23
+ from diffneusim.model import bodies, body_info
24
+ shipped = "; ".join(f"{n}: {body_info(n)['tag']}" for n in bodies() if body_info(n).get("tag"))
25
+ return ("D16_BODY is not set: a run must name its body's engine build. Set D16_BODY (every task file in diffneusim-paper does) to "
26
+ f"one of the shipped bodies' builds ({shipped}) or one of a body's contact floors (models/BODIES.toml)")
27
+
28
+
29
+ assert TAG, _no_body() # the 14x default this module once fell back to does not ship
30
+ _h = GPU / "generated" / f"body_{TAG}.cuh"
31
+ assert _h.exists(), f"D16_BODY={TAG}: no {_h}: tools/d16_bodies/gen_body.py"
32
+ V = _read(_h)
33
+ _hash, _, _variant = TAG.partition("_")
34
+ _laws = sorted((ROOT / "models" / "derived").glob(f"d16_soft_law_{_hash}*{'_' + _variant if _variant else ''}.json"))
35
+ if not _variant:
36
+ _laws = [p for p in _laws if "_mmfloor" not in p.name]
37
+ assert len(_laws) == 1, f"D16_BODY={TAG}: the law JSON: {_laws}"
38
+ LAW = _laws[0]
39
+ _m = re.search(r"^// model: (\S+)$", _h.read_text(), re.M)
40
+ assert _m is not None, f"{_h}: no model line: tools/d16_bodies/gen_body.py --model"
41
+ MODEL = ROOT / "models" / _m.group(1)
42
+ assert V, "no D16_BODY_ values read"
43
+ NQ, NV, NM, NPOSE, NTRI, NPR = V["NQ"], V["NV"], V["NM"], V["NPOSE"], V["NTRI"], V["NPR"]
44
+ TAPE_WORDS, TAPE_MUS = V["TAPE_WORDS"], V["TAPE_MUS"]
45
+ QUATS = (3, V["BQ0"], V["BQ1"])
46
+ # the x14 header the build compiles: the body header's include
47
+ _x = re.search(r'^#include "soft/gpu/generated/(x14_soft_\w+\.cuh)"$', _h.read_text(), re.M)
48
+ assert _x is not None, f"{_h}: no x14 header include"
49
+ X14 = GPU / "generated" / _x.group(1)
50
+ _xt = X14.read_text()
51
+ NLIM = int(re.search(r"\bNLIM = (\d+)\b", _xt).group(1))
52
+ _nlw = re.search(r"\bNLW = (\d+)\b", _xt)
53
+ NLW = int(_nlw.group(1)) if _nlw else None
54
+ # a phase B body (NV > 64, PHASE_B.md): every build carries D16_NV_GT64, and the record's factors are the split storage's words (its generated
55
+ # split header, gen_split.py), not NTRI (B3c item 4)
56
+ PHASE_B = NV > 64
57
+ SPLIT_WORDS = None
58
+ if PHASE_B:
59
+ _sw = re.findall(r"\bWORDS = (\d+)\b", (GPU / "generated" / f"split_{TAG}.cuh").read_text())
60
+ assert len(set(_sw)) == 1, _sw
61
+ SPLIT_WORDS = int(_sw[0])
62
+ assert len(json.loads(LAW.read_text())["limits"]) == NLIM, f"{LAW.name} and {X14.name} disagree on the limits: regenerate the header (tools/d16_14x/gen14.py)"
63
+
64
+
65
+ def fused(mrg, model, outdir):
66
+ """The fused model a CPU reference loads. D16_FUSED names the file the case was exported from. Otherwise it is fused here, which is host dependent: the arithmetic on ARM and x86 differs in the last bits (Mac
67
+ against Linux on the armless: 204 of 13,221 numbers, at most 1.2e-14 relative), and so does the file's content tag. A gate that compares a CPU reference with a case's device run should set it."""
68
+ return mrg.fused(model, outdir)
69
+
70
+
71
+ def build_flags():
72
+ """the compile flag of a build for this body: one argv entry, no shell quoting (torch's ninja build needs engine14's own form)"""
73
+ return ([f'-DD16_BODY_HEADER="soft/gpu/generated/body_{TAG}.cuh"'] + (["-DD16_NV_GT64"] if PHASE_B else [])) if TAG else []
74
+
75
+
76
+ def cpu_flags():
77
+ """(B3d) the flags of the composed CPU library (tools/d16_14x/x14c_capi.cpp: soft14_capi plus the CPU muscle stage) for a phase B body: the
78
+ macro's law variant, and the muscle stage's site and row capacities from the body header (muscle_ref_gate.cpp's MUSREF_NS / MUSREF_KD; its
79
+ defaults are the 14x's 10 / 6, and load_model's CHECK stops the 416's 12-site muscles). Empty for the 14x and phase A, whose builds stay as they were"""
80
+ return ["-DD16_NV_GT64", f"-DMUSREF_NS={V['NS']}", f"-DMUSREF_KD={V['MKD']}"] if PHASE_B else []
@@ -0,0 +1,367 @@
1
+ """The 14x engine (bindings/soft14_engine_ext.cu): the composed forward k_mus -> k_pre14 -> order -> k_post14 -> tail, one control
2
+ step of NSUB substeps on device tensors. The model: the generated law values (compiled in) and the muscle tables from a
3
+ case directory (case.json + case.bin; diffneusim.model.read_case).
4
+ e = Engine14(n, dtype); out = e.control_step(q, v, warm, lce, a, u[, record=True])
5
+ State convention: the law's (MuJoCo's); soft14.from_old_engine converts the old engine's qd."""
6
+ import importlib.util
7
+ import os
8
+ import pathlib
9
+ import re
10
+
11
+ import numpy as np
12
+ import torch
13
+
14
+ HERE = pathlib.Path(__file__).resolve().parent
15
+ from diffneusim._paths import ROOT as ROOT # (3a) the repo root
16
+ # (3a) was: sys.path.insert(0, str(ROOT / "tools" / "d16_bodies"))
17
+ from diffneusim.engine import d16_body as BODY # noqa: E402 # the process's body: D16_BODY=<tag>, unset the 14x (PORT_DESIGN.md section 5)
18
+ NQ, NV, NM, NSUB, KFIB, DT = BODY.NQ, BODY.NV, BODY.NM, 5, 6, 0.002
19
+ SIZE_FIELDS = ("nq", "nv", "nm", "nb", "npr", "nsub", "ns", "mkd", "nslot") # the extension's sizes()
20
+ # Millard's reset (the review's decision (a), 11-05; tools/d16_x14adj/MILLARD14.md gate 6): the equilibration's rounds run the fibre solve at a
21
+ # larger dt than DT. Every round's fixed point is the static (v = 0) root at any dt, and a larger dt takes larger pseudo-time steps, so the
22
+ # rounds reach it fast; at DT, 8 damped rounds leave up to 5.5e-2 F_max. A very large dt alone (100) removes the damping that conditions the
23
+ # Newton and, from a cold start, cycles on the active curve's descending limb with a slack tendon (addmagProx_r at A = 1: 0.88 F_max). So
24
+ # the outer rounds run at EQUIL_DT_MILLARD[0] (the damping still conditions them) and EQUIL_POLISH_MILLARD more at EQUIL_DT_MILLARD[1]:
25
+ # 1.4e-11 F_max on the case's warm states and 5.4e-6 on the jump clip's cold starts (CPU f64, 8 + 4 rounds). Geyer's reset keeps DT and its
26
+ # 8 damped rounds (by design: not the isometric root; the census needed up to 1,229 rounds for that), so its call is unchanged.
27
+ EQUIL_DT_MILLARD, EQUIL_POLISH_MILLARD = (0.1, 2.0), 4
28
+ # ENGINE14_KFIB=n: the fibre's Newton count for this process (eval-only, tools/e0_eval_f64/FIBRE_CONV.md). Unset: KFIB.
29
+ KFIB_RUN = int(os.environ.get("ENGINE14_KFIB", str(KFIB)))
30
+ assert KFIB_RUN >= 1, KFIB_RUN
31
+ _s = importlib.util.spec_from_file_location("case_tables", ROOT / "engine" / "case_tables.py")
32
+ KG = importlib.util.module_from_spec(_s); _s.loader.exec_module(KG)
33
+ _s = importlib.util.spec_from_file_location("d16_build_tag", ROOT / "engine" / "build_tag.py")
34
+ BT = importlib.util.module_from_spec(_s); _s.loader.exec_module(BT)
35
+ _EXT = {}
36
+
37
+
38
+ ADJ5 = False # (11-08; up/PREREG_X14ADJ5.md, 1a's conditions) the D16 tools' --adj5 sets it; no paper / paper_package / bench_final path does (bench.py asserts)
39
+ ROWCF = False # (11-08; rowcf/PREREG_X14ROWCF.md, 1a's conditions) the D16 tools' --rowcf sets it; no paper / paper_package / bench_final path does (bench.py asserts)
40
+ KPOST9 = False # (11-09; kpost9/PREREG_KPOST9.md, 1a's conditions) the 416's kpost14 at 9 per SM; the D16 tools' --kpost9 sets it; no paper / paper_package / bench_final path does
41
+
42
+
43
+ def load_ext(fmad=True, millard=False, body=None, adj5=None, rowcf=None, kpost9=None):
44
+ """millard: the Millard 2013 muscle law (-DD16_X14_MILLARD; a Millard case, tools/d16_x14adj/MILLARD14.md). body: a body's tag, the
45
+ extension for core/soft/gpu/generated/body_<tag>.cuh (tools/d16_bodies/gen_body.py), by default D16_BODY's. Unset, the 14x's Geyer build. The
46
+ tag hashes every header the build reads and the body's own (PORT_DESIGN.md 7.8), and body is in _EXT's key, so a re-exported header or
47
+ another body never reuses a cached extension."""
48
+ body = body if body is not None else (BODY.TAG or None)
49
+ adj5 = ADJ5 if adj5 is None else adj5
50
+ assert not (adj5 and body is not None), "D16_X14_ADJ5 is the 14x's lever (a phase B body has stage A already)"
51
+ rowcf = ROWCF if rowcf is None else rowcf
52
+ assert not (rowcf and body is not None), "D16_X14_ROWCF is the 14x's lever (a body header sets D16_BODY_ROW_CF itself)"
53
+ kpost9 = KPOST9 if kpost9 is None else kpost9
54
+ key = (fmad, millard, body, adj5, rowcf) + ((True,) if kpost9 else ()) # (the default's key unchanged)
55
+ if key in _EXT:
56
+ return _EXT[key]
57
+ from torch.utils.cpp_extension import load
58
+ flags = ["-O3", "-std=c++17", "-lineinfo", "-DNDEBUG"] + ([] if fmad else ["-fmad=false"]) + (["-DD16_X14_MILLARD"] if millard else [])
59
+ v = os.environ.get("X14_VARIANT", "mm") # soft14.VARIANT's default: the floor-contact set
60
+ assert v in ("mm", "e0"), f"X14_VARIANT={v!r}: mm or e0"
61
+ SOFT = ROOT / "core" / "soft"
62
+ extra = []
63
+ if body is not None:
64
+ h = SOFT / "gpu" / "generated" / f"body_{body}.cuh"
65
+ assert h.exists(), f"no body header {h}: tools/d16_bodies/gen_body.py"
66
+ extra = [h]
67
+ flags += [f"""'-DD16_BODY_HEADER="soft/gpu/generated/{h.name}"'"""] # single quotes: torch's build runs the flags through a shell
68
+ nv = int(re.search(r"#define D16_BODY_NV (\d+)", h.read_text()).group(1))
69
+ if nv > 64: # B3d: a phase B body builds only with its macro (its x14 header's #error otherwise; d16_body.build_flags)
70
+ flags += ["-DD16_NV_GT64"]
71
+ elif v == "mm":
72
+ flags += ["-DD16_X14_MMFLOOR"]
73
+ assert not kpost9 or (body is not None and "-DD16_NV_GT64" in flags), "D16_B416_KPOST9 is the 416's kpost14 lever (a phase B body)"
74
+ if adj5:
75
+ flags += ["-DD16_X14_ADJ5"]
76
+ if rowcf:
77
+ flags += ["-DD16_X14_ROWCF"]
78
+ if kpost9:
79
+ flags += ["-DD16_B416_KPOST9"]
80
+ srcs = ([ROOT / "bindings" / "soft14_engine_ext.cu"] + sorted((SOFT / "gpu").glob("*.cuh")) + sorted((SOFT / "gpu").glob("*.h")) + sorted(SOFT.glob("*.h"))
81
+ + sorted((SOFT / "gpu" / "generated").glob("x14_*.cuh")) + sorted((SOFT / "x14").glob("*.h")) + sorted((SOFT / "x14adj").glob("*.h")) + extra)
82
+ tag = BT.tag(ROOT, srcs, flags) # the flags and every file the build reads: srcs, their include closure, every generated header
83
+ e = load(name=f"soft14_engine_{tag}", sources=[str(srcs[0])], extra_include_paths=[str(ROOT / "core"), str(ROOT / "core" / "include")],
84
+ extra_cuda_cflags=flags, extra_cflags=["-O2", "-std=c++17"], verbose=False)
85
+ _EXT[key] = e
86
+ return e
87
+
88
+
89
+ def init_model(e, case_dir, C=None):
90
+ C = KG.load_case(case_dir) if C is None else C
91
+ s = dict(zip(SIZE_FIELDS, e.sizes()))
92
+ d = [int(x) for x in C["dims"]]
93
+ assert (d[0], d[1], d[2], d[4]) == (s["nq"], s["nv"], s["nm"], s["nslot"]), f"the case's nq, nv, nm, nslot are not this extension's {s} ({case_dir})"
94
+ assert int(e.law()) == int(KG.is_millard(C)), f"the extension's muscle law ({int(e.law())}) is not the case's ({case_dir})"
95
+ rig = np.asarray(C["rigid"]) # feat/d16-rigid2: rigid = 2 needs the X14_RIGID2 build (else the device treats it as rigid = 1)
96
+ assert set(np.unique(rig).tolist()) <= {0, 1, 2}, np.unique(rig)
97
+ assert not (rig == 2).any(), \
98
+ "the case has rigid = 2 muscles: build the engine with X14_RIGID2=1 (else the device treats them as rigid = 1)"
99
+ # rigid2's `model_of(C) == 1` ("the 14x case") would refuse every body build (the 290, the 14x rom23), and the rigid = 2 code is
100
+ # not body-specific: it is per muscle in muscle.h, and the dims assert above ties the case to this extension. What IS specific is
101
+ # the law: rigid = 2's damping and floor exist only in the Geyer branch (geyer_rigid, muscle_fiber_vjp under D16_RIGID2_ON);
102
+ # Millard's millard_rigid takes any nonzero rigid as 1, so a Millard case with rigid = 2 would run as rigid = 1 silently.
103
+ assert not ((rig == 2).any() and KG.is_millard(C)), f"rigid = 2 is the Geyer law's (muscle.h geyer_rigid); this case is Millard ({case_dir})"
104
+ if "perm" not in C:
105
+ C["perm"] = np.arange(s["nm"], dtype=np.int32)
106
+ tabs = {}
107
+ for ft, key in ((np.float32, 32), (np.float64, 64)):
108
+ lst = []
109
+ for k in KG.TABLE + ["perm"] + KG.law_names(C):
110
+ a = C[k]
111
+ a = np.ascontiguousarray(a, dtype=ft if (k in KG.FLOATS or a.dtype.kind == "f") else np.int32)
112
+ lst.append(torch.from_numpy(a))
113
+ tabs[key] = lst
114
+ e.init(tabs[32], tabs[64], KG.bind_dims(C))
115
+ return C
116
+
117
+
118
+ class Engine14:
119
+ def __init__(self, n, dtype=torch.float32, case_dir=None, device="cuda", equil_kfib=None):
120
+ assert case_dir is not None, "the muscle case directory"
121
+ C = KG.load_case(case_dir)
122
+ self.millard = KG.is_millard(C) # the case's muscle law selects the build (one law per model)
123
+ # (2026-11-17; the review GO, ISSUE 2) a Millard case with at least one compliant muscle runs its reset rounds in float64
124
+ # (equil_lce); an all-rigid case (M290R) has no fibre Newton and keeps the shipped float32 lines
125
+ self.millard_f64_reset = bool(self.millard and not np.all(np.asarray(C["rigid"]) != 0))
126
+ self.millard_polish = None # the last f64 Millard reset's end states (l_prev, l_end, l_more, a, dt) for env14's logged counter
127
+ self.equil_log = [] # the first reset's kernel launches as (rounds, dt), for the trainer's log (env14.install_equil14)
128
+ # the reset's Newton count: KFIB_RUN (ENGINE14_KFIB, else KFIB) unless set; env14's E0_ENV14_RESET32 sets KFIB, the policy's own reset
129
+ self.equil_kfib = KFIB_RUN if equil_kfib is None else int(equil_kfib)
130
+ assert self.equil_kfib >= 1, self.equil_kfib
131
+ # X14_EQUIL_SCHEDULE="rounds:dt,..." (the Geyer-root arm, the review 11-06): a Geyer case's reset runs these launches of the fibre solve
132
+ # (the first from the seed, the rest in place) instead of `outer` rounds at DT, so it can reach the static root as Millard's does.
133
+ # Unset: the Geyer reset is unchanged. A Millard case refuses it (its schedule is EQUIL_DT_MILLARD's).
134
+ sch = ""
135
+ self.equil_schedule = None
136
+ assert self.equil_schedule is None or (not self.millard and all(r >= 1 and d > 0 for r, d in self.equil_schedule)), \
137
+ f"X14_EQUIL_SCHEDULE={sch!r}: Geyer cases only, rounds >= 1, dt > 0"
138
+ # X14_MILLARD_EQUIL_SCHEDULE="rounds:dt,..." (2026-11-18; the review after EQROOT: the Geyer hard-start cell from a SETTLED start
139
+ # failed as Millard step 4 did, so the Millard body gets the Geyer walking reset's start as an option): a Millard case's reset runs
140
+ # these launches of the fibre solve (the first from the seed, the rest in place) INSTEAD of EQUIL_DT_MILLARD / EQUIL_POLISH_MILLARD.
141
+ # "8:0.002" = the Geyer walking reset (8 rounds at DT from the l_opt seed): unconverged BY DESIGN, not the static root. Unset: the
142
+ # Millard reset is today's code, unchanged. A Geyer case refuses it (its key is X14_EQUIL_SCHEDULE). The f64 rounds of a float32
143
+ # engine and env14's logged counter keep working (_equil_millard_scheduled).
144
+ msch = os.environ.get("X14_MILLARD_EQUIL_SCHEDULE", "")
145
+ self.millard_schedule = [(int(r), float(d)) for r, d in (x.split(":") for x in msch.split(","))] if msch else None
146
+ assert self.millard_schedule is None or (self.millard and all(r >= 1 and d > 0 for r, d in self.millard_schedule)), \
147
+ f"X14_MILLARD_EQUIL_SCHEDULE={msch!r}: Millard cases only, rounds >= 1, dt > 0"
148
+ # X14_MILLARD_RESET_F32=1, the imitation task's reset precision: the schedule's rounds run at the engine's precision, in place, as the
149
+ # paper's KIT imitation runs ran them (52380ef6a, cac6a2628). Unset, a float32 engine with compliant muscles runs them on float64 copies,
150
+ # the predictive walking line's setting. Each line keeps its own numerics; neither is a fallback for the other.
151
+ r32 = os.environ.get("X14_MILLARD_RESET_F32", "0")
152
+ assert r32 in ("0", "1"), f"X14_MILLARD_RESET_F32={r32!r}: 0 or 1"
153
+ self.millard_reset_f32 = r32 == "1"
154
+ assert not self.millard_reset_f32 or self.millard_schedule is not None, \
155
+ "X14_MILLARD_RESET_F32 sets the precision of X14_MILLARD_EQUIL_SCHEDULE's rounds: set the schedule too"
156
+ self.ext = load_ext(fmad=dtype == torch.float32, millard=self.millard)
157
+ self.case = init_model(self.ext, case_dir, C)
158
+ self.n, self.dt = n, dtype
159
+ self.sizes = dict(zip(SIZE_FIELDS, self.ext.sizes()))
160
+ assert (self.sizes["nq"], self.sizes["nv"], self.sizes["nm"], self.sizes["nsub"]) == (NQ, NV, NM, NSUB), self.sizes
161
+ f = lambda *s: torch.zeros(*s, dtype=dtype, device=device) # noqa: E731
162
+ i = lambda *s, dt=torch.int32: torch.zeros(*s, dtype=dt, device=device) # noqa: E731
163
+ self.o = dict(oq=f(n, NQ), ov=f(n, NV), ow=f(n, NV), olce=f(n, NM), oa=f(n, NM))
164
+ self.s = dict(sq=f(n, NQ), sv=f(n, NV), sw=f(n, NV), slce=f(n, NM), sa=f(n, NM), tau=f(n, NV), hand=f(n, int(self.ext.hand_words())), aadv=f(n, NV))
165
+ self.i = dict(nefc=i(n), order=i(n), nbig=i(1), niter=i(n), kflags=i(n), nls=i(n), nfact=i(n), cycles=i(n, dt=torch.int64), flags=i(n),
166
+ stats=i(n, NSUB, 6))
167
+ self.rec = dict(tau=f(NSUB, n, NV), lce=f(NSUB, n, NM), a=f(NSUB, n, NM))
168
+ self.empty = f(0)
169
+
170
+ def control_step(self, q, v, warm, lce, a, u, record=False, parts=15, tape=None):
171
+ """tape: None (untaped, the record-off kernels) or rec_h [nsub, n, words], this control step's slice of alloc_tape: k_mus
172
+ writes MUS, k_pre14 POSE, k_post the rest. No control record: the adjoint reads the step's own a and u."""
173
+ o, s, i = self.o, self.s, self.i
174
+ r = [self.rec["tau"], self.rec["lce"], self.rec["a"]] if record else [self.empty] * 3
175
+ t = [tape if tape is not None else self.empty]
176
+ b = [q, v, warm, lce, a, u, o["oq"], o["ov"], o["ow"], o["olce"], o["oa"], s["sq"], s["sv"], s["sw"], s["slce"], s["sa"], s["tau"],
177
+ s["hand"], i["nefc"], i["order"], i["nbig"], i["niter"], i["kflags"], i["nls"], i["nfact"], i["cycles"], i["flags"], i["stats"], *r, s["aadv"],
178
+ *t]
179
+ self.ext.control_step(b, NSUB, KFIB_RUN, DT, parts)
180
+ return dict(qpos=o["oq"], qvel=o["ov"], warm=o["ow"], lce=o["olce"], a=o["oa"], stats=i["stats"], flags=i["flags"])
181
+
182
+ def equil_lce(self, q, lce, a0, mask, outer=8, out=None):
183
+ """P1 (tools/e0speed/CAPTURE_PLAN.md): the reset's fibre equilibrium on this law. q [n, NQ] (the law chart), lce / a0
184
+ [n, NM], mask [n] (bool or uint8: the worlds to equilibrate; the others copy lce through) -> lce [n, NM] (into `out`,
185
+ which may be lce itself). outer rounds of the stage's fibre solve (KFIB Newton steps each) at A = a0 with
186
+ l_ce_prev <- l_ce, as mtu_gpu.equilibrate_fibers iterates the old engine's coupling call (its default 8 rounds). A Millard case's
187
+ outer rounds run at EQUIL_DT_MILLARD[0], then EQUIL_POLISH_MILLARD more at EQUIL_DT_MILLARD[1] (in place), so they reach the static root."""
188
+ out = torch.empty_like(lce) if out is None else out
189
+ m = mask.to(torch.uint8).contiguous()
190
+ if not self.millard and self.equil_schedule is None:
191
+ self._equil([q, lce, a0, m, out], int(outer), DT)
192
+ return out
193
+ if not self.millard: # X14_EQUIL_SCHEDULE replaces the round count: refuse a non-default DN_FIBER_INIT_ITERS rather than ignore it
194
+ assert int(outer) == 8, f"X14_EQUIL_SCHEDULE with outer {outer}: the schedule sets the rounds"
195
+ src = lce
196
+ for r, d in self.equil_schedule:
197
+ self._equil([q, src, a0, m, out], r, d)
198
+ src = out
199
+ return out
200
+ if self.millard_schedule is not None: # X14_MILLARD_EQUIL_SCHEDULE (an option, OFF by default): the branches below are not entered
201
+ return self._equil_millard_scheduled(q, lce, a0, m, outer, out)
202
+ if self.millard_f64_reset and lce.dtype == torch.float32:
203
+ # (2026-11-17; the review GO, ISSUE 2: the f32 reset miss) the same rounds on float64 copies through the same extension,
204
+ # rounded to float32 once at the end. The f32 fibre Newton's undamped step (muscle.h millard_fiber) threw short trunk fibres
205
+ # off the root at the reset's large dt (gate 6; g6where 11-17: M290C state 227 LTpL_L1_r, f32 0.799 against the f64 0.238
206
+ # l_opt); the f64 rounds match the CPU f64 reference (0 pairs off on case and reset states). No clamp, no retry, no fallback.
207
+ # (23:4x, the review) the polish's LAST round runs as its own launch so the state before it is kept: env14's logged counter
208
+ # takes the tendon force at a round's end as the fibre side at that round's own velocity (millard_curves_torch). The same kernel
209
+ # rounds in the same order as one launch of EQUIL_POLISH_MILLARD (gated bitwise); the log still names the schedule (4, 2.0).
210
+ # Then ONE further f64 polish round from the result, for the counter only (the result is the schedule's end).
211
+ q64, a64, l64 = q.double(), a0.double(), lce.double()
212
+ self._equil([q64, l64, a64, m, l64], int(outer), EQUIL_DT_MILLARD[0])
213
+ if len(self.equil_log) < max(2, len(self.equil_schedule or ())):
214
+ self.equil_log.append((EQUIL_POLISH_MILLARD, EQUIL_DT_MILLARD[1]))
215
+ self.ext.equil_lce([q64, l64, a64, m, l64], self.equil_kfib, EQUIL_POLISH_MILLARD - 1, EQUIL_DT_MILLARD[1])
216
+ l_prev = l64.clone()
217
+ self.ext.equil_lce([q64, l64, a64, m, l64], self.equil_kfib, 1, EQUIL_DT_MILLARD[1])
218
+ chk = torch.empty_like(l64)
219
+ self.ext.equil_lce([q64, l64, a64, m, chk], self.equil_kfib, 1, EQUIL_DT_MILLARD[1])
220
+ self.millard_polish = dict(l_prev=l_prev, l_end=l64, l_more=chk, a=a64, dt=float(EQUIL_DT_MILLARD[1]))
221
+ out.copy_(l64)
222
+ return out
223
+ self._equil([q, lce, a0, m, out], int(outer), EQUIL_DT_MILLARD[0])
224
+ self._equil([q, out, a0, m, out], EQUIL_POLISH_MILLARD, EQUIL_DT_MILLARD[1])
225
+ return out
226
+
227
+ def equil_residual(self, q, lce, a0, mask):
228
+ """|one further round of the fibre solve at the step's DT from lce - lce| [n, NM]: how far the first substep's fibre solve would
229
+ move a reset fibre with q and A held, i.e. its spurious fibre velocity times DT. For the trainer's log only; no state is written."""
230
+ out = torch.empty_like(lce)
231
+ self.ext.equil_lce([q, lce, a0, mask.to(torch.uint8).contiguous(), out], self.equil_kfib, 1, DT)
232
+ return (out - lce).abs()
233
+
234
+ def _equil_millard_scheduled(self, q, lce, a0, m, outer, out):
235
+ """X14_MILLARD_EQUIL_SCHEDULE's reset (2026-11-18): the schedule's launches of the stage's fibre solve on a Millard case, the
236
+ first from the seed, the rest in place. On a float32 engine with compliant muscles they run on float64 copies through the same
237
+ extension, rounded to float32 once, as the default Millard reset's rounds do; the schedule's LAST round runs as its own launch and
238
+ one further round from the result is taken for env14's logged counter only (millard_polish, at the last launch's dt), as the
239
+ default branch does. The log holds the schedule itself, written once."""
240
+ assert int(outer) == 8, f"X14_MILLARD_EQUIL_SCHEDULE with outer {outer}: the schedule sets the rounds"
241
+ sch = self.millard_schedule
242
+ if not self.equil_log:
243
+ self.equil_log.extend(sch)
244
+ if self.millard_f64_reset and lce.dtype == torch.float32 and not self.millard_reset_f32:
245
+ q64, a64, l64 = q.double(), a0.double(), lce.double()
246
+ for r, d in sch[:-1]:
247
+ self.ext.equil_lce([q64, l64, a64, m, l64], self.equil_kfib, r, d)
248
+ r, d = sch[-1]
249
+ if r > 1:
250
+ self.ext.equil_lce([q64, l64, a64, m, l64], self.equil_kfib, r - 1, d)
251
+ l_prev = l64.clone()
252
+ self.ext.equil_lce([q64, l64, a64, m, l64], self.equil_kfib, 1, d)
253
+ chk = torch.empty_like(l64)
254
+ self.ext.equil_lce([q64, l64, a64, m, chk], self.equil_kfib, 1, d)
255
+ self.millard_polish = dict(l_prev=l_prev, l_end=l64, l_more=chk, a=a64, dt=float(d))
256
+ out.copy_(l64)
257
+ return out
258
+ src = lce
259
+ for r, d in sch:
260
+ self.ext.equil_lce([q, src, a0, m, out], self.equil_kfib, r, d)
261
+ src = out
262
+ return out
263
+
264
+ def _equil(self, b, rounds, dt):
265
+ if len(self.equil_log) < max(2, len(self.equil_schedule or ())):
266
+ self.equil_log.append((rounds, dt))
267
+ self.ext.equil_lce(b, self.equil_kfib, rounds, dt) # KFIB_RUN by default (main's ENGINE14_KFIB convention)
268
+
269
+ def zero_flags(self):
270
+ self.i["flags"].zero_()
271
+
272
+ def adjoint(self, rec_h, a0, u, wq, wv):
273
+ """One control step's backward (the adj14_control_step): the step's records rec_h [nsub, n, words], its inputs a0 / u
274
+ [n, NM], the cotangents of (q_{t+1}, v_{t+1}) in the tangent chart [n, NV] -> (qbar, vbar) [n, NV] of (q_t, v_t), flags [n].
275
+ Rigid until the step 4 (the muscle_adj)."""
276
+ qbar, vbar = torch.empty_like(wq), torch.empty_like(wv)
277
+ flags = torch.zeros(wq.shape[0], dtype=torch.int32, device=wq.device)
278
+ self.ext.adjoint([rec_h, a0, u, wq, wv, qbar, vbar, flags])
279
+ return qbar, vbar, flags
280
+
281
+ def adjoint_mus_raw(self, rec_h, a0, u, lce1, q, q1, gq1, gv1, glce1, ga1):
282
+ """The composed backward (the step 4: the rigid adjoint and the muscle_adj per substep) in raw coordinates: the step's
283
+ records, a0 / u / lce1 (its a, u and output lce), q / q1, the loss's cotangents (zeros where it has none) ->
284
+ (gq, vbar, lcebar, actbar, ubar, flags [nsub, n]). The scratch is allocated once per n."""
285
+ n = q.shape[0]
286
+ if getattr(self, "_adj_scr", None) is None or self._adj_scr.numel() != int(self.ext.mus_scratch_elems(n)) \
287
+ or self._adj_scr.dtype != q.dtype:
288
+ self._adj_scr = torch.empty(int(self.ext.mus_scratch_elems(n)), dtype=q.dtype, device=q.device)
289
+ gq, vbar = torch.empty_like(q), torch.empty_like(gv1)
290
+ lbar, abar, ubar = torch.empty_like(a0), torch.empty_like(a0), torch.empty_like(a0)
291
+ flags = torch.zeros(NSUB, n, dtype=torch.int32, device=q.device)
292
+ self.ext.adjoint_mus_raw([rec_h, a0, u, lce1, q, q1, gq1, gv1, glce1, ga1, gq, vbar, lbar, abar, ubar, flags, self._adj_scr])
293
+ return gq, vbar, lbar, abar, ubar, flags
294
+
295
+ def adjoint_raw(self, rec_h, a0, u, q, q1, gq1, gv1):
296
+ """The backward in raw coordinates (Step14's call): the boundary charts fused around the adjoint in the binding (two
297
+ kernels), q / q1 the step's input / output, gq1 / gv1 the loss's cotangents -> (gq, vbar, flags)"""
298
+ gq, vbar = torch.empty_like(q), torch.empty_like(gv1)
299
+ flags = torch.zeros(q.shape[0], dtype=torch.int32, device=q.device)
300
+ self.ext.adjoint_raw([rec_h, a0, u, q, q1, gq1, gv1, gq, vbar, flags])
301
+ return gq, vbar, flags
302
+
303
+
304
+ # ---- the 14x tape (2026-11-03; docs-dev/engine-model/20261102_d16_engine_redesign/TAPE_POLICY_38.md, the decision 2) ----
305
+ TAPE_FIELDS = ("words", "hdr", "flags", "min_nu", "clamp", "zone", "con", "qpos", "qvel", "qacc", "qadv", "LH", "LQ", "pose", "mus",
306
+ "n_clamp", "n_zone", "n_con", "ctl_words", "ctl_u")
307
+ TAPE_BUDGET_BYTES = 16e9 # the policy's default budget for the tape on a 24 GB card (decimal GB, as the memo's sizes)
308
+
309
+
310
+ def tape_layout(npose=BODY.NPOSE, nmus=BODY.NM, nq=BODY.NQ, nv=BODY.NV, maxcon=64, maxrows=255, npair=BODY.NPR):
311
+ """The 14x substep record and the per-control-step muscle record, from core/soft/tape.h itself (the CPU library's
312
+ s14_tape_layout): Euler, so no L_Q block; POSE = kernel P's 66 bodies (0 to leave it out); MUS = lce_prev [356]. The defaults are the
313
+ process's body."""
314
+ import ctypes
315
+ from diffneusim.engine import soft14
316
+ soft14.build()
317
+ lib = ctypes.CDLL(str(soft14.LIB))
318
+ out = np.zeros(len(TAPE_FIELDS), np.int32)
319
+ if BODY.PHASE_B: # B3c item 4: a phase B record's layout names the limit count and the split words (tape.h; soft14_capi's s14_tape_layout_b)
320
+ assert "-DD16_NV_GT64" in soft14.EXTRA, "a phase B body's CPU library is the D16_NV_GT64 variant: SOFT14_EXTRA=-DD16_NV_GT64"
321
+ # (3a) was: sys.path.insert(0, str(ROOT / "tools" / "d16_bodies"))
322
+ from diffneusim.engine import gen_split
323
+ _, _, wmap = gen_split.split_header(BODY.LAW)
324
+ wm = np.ascontiguousarray(wmap, np.int32)
325
+ lib.s14_set_split(wm.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), len(wm), max(wmap) + 1)
326
+ assert max(wmap) + 1 == BODY.SPLIT_WORDS, (max(wmap) + 1, BODY.SPLIT_WORDS)
327
+ lib.s14_tape_layout_b(nq, nv, maxcon, maxrows, npose, nmus, npair, BODY.NLIM, out.ctypes.data_as(ctypes.POINTER(ctypes.c_int)))
328
+ else:
329
+ lib.s14_tape_layout(nq, nv, maxcon, maxrows, npose, nmus, npair, out.ctypes.data_as(ctypes.POINTER(ctypes.c_int)))
330
+ return dict(zip(TAPE_FIELDS, (int(x) for x in out)))
331
+
332
+
333
+ def tape_budget_bytes():
334
+ """The tape budget: X14_TAPE_BUDGET_GB (decimal GB) when set, for a larger card (the H200's 141 GB: the cluster job, 4,096 x
335
+ H128 = 18.8 GB), else TAPE_BUDGET_BYTES, the 24 GB card's 16 GB. The override is not checked against the device: a budget
336
+ the card cannot hold fails at the tape's allocation."""
337
+ v = None
338
+ return TAPE_BUDGET_BYTES
339
+ gb = float(v)
340
+ assert gb > 0, f"X14_TAPE_BUDGET_GB={v!r} must be a positive number of GB"
341
+ return gb * 1e9
342
+
343
+
344
+ def tape_plan(n_worlds, horizon, nsub=5, npose=BODY.NPOSE, nmus=BODY.NM, word_bytes=4, budget_bytes=None):
345
+ """TAPE_POLICY's rule for the 14x: full records (every substep's record kept for the whole horizon) while
346
+ n x H x nsub x words x word_bytes fits the budget (budget_bytes, else tape_budget_bytes()); above it the policy's option (a),
347
+ checkpoints and a re-forward per control step, which is not built: refused (fail fast) rather than run without a tape. (No
348
+ control record: the autograd Function keeps each step's a_0 and u, which the adjoint reads.)"""
349
+ if budget_bytes is None:
350
+ budget_bytes = tape_budget_bytes()
351
+ L = tape_layout(npose, nmus)
352
+ per_step = n_worlds * nsub * L["words"] * word_bytes
353
+ total = per_step * horizon
354
+ mode = "full" if total <= budget_bytes else "checkpoint"
355
+ return dict(mode=mode, bytes=int(total), bytes_per_control_step=int(per_step), layout=L, n_worlds=n_worlds, horizon=horizon,
356
+ nsub=nsub, word_bytes=word_bytes, budget_bytes=budget_bytes)
357
+
358
+
359
+ def alloc_tape(plan, device="cuda"):
360
+ """The full tape for a plan: rec [H, nsub, n, words] in the record's word type (float32: the f32 production; float64: the f64
361
+ build the dot test runs). Words are written by their kernels (k_post: the record but POSE / MUS; k_pre14: POSE; k_mus: MUS);
362
+ nothing is zeroed here (tape.h: every word has one writer)."""
363
+ assert plan["mode"] == "full", (f"tape {plan['bytes'] / 1e9:.1f} GB over the {plan['budget_bytes'] / 1e9:.0f} GB budget: "
364
+ "TAPE_POLICY option (a), checkpoints with a re-forward, is not built")
365
+ dt = {4: torch.float32, 8: torch.float64}[plan["word_bytes"]]
366
+ L = plan["layout"]
367
+ return torch.empty(plan["horizon"], plan["nsub"], plan["n_worlds"], L["words"], dtype=dt, device=device)
@@ -0,0 +1,159 @@
1
+ """PHASE_B.md section 4's tables (2026-11-06; step B3a): the split factor's layout for a body, from its law, as a generated header. Refuses a body the split is not exact on (phase_b_tree.py's checks).
2
+ E = the dofs of the bodies below a wrist, in chains (one per wrist child: the thumb and the four fingers on each hand); the core = the rest, in ascending dof order.
3
+ Emitted, for core/soft/gpu/chol_split.cuh:
4
+ NV, NC (core dofs), NCH (chains), CL (dofs per chain), NA (core ancestors per chain), and the storage: the core's packed triangle [0, NTRI_C), then per chain its CL x CL lower triangle
5
+ and its NA x CL rows against its core ancestors;
6
+ gSplitCore[NC] the core's dofs (global)
7
+ gSplitChain[NCH][CL] each chain's dofs (global) in elimination order: the leaf first
8
+ gSplitAnc[NCH][NA] each chain's core ancestors (core-local, ascending)
9
+ gSplitUpd / gSplitUpdOff per core packed entry e, its Schur updates in a fixed order: c << 16 | ai << 8 | aj (chain, the two ancestors' positions in the chain's list)
10
+ gSplitRu / gSplitRuOff per core dof i, the chains that reach it: c << 8 | a
11
+ gSplitWord[NTRI] per dense packed entry (i, j) of the global dof order, i >= j, its word in the split storage, -1 where the split holds a structural zero; every entry of
12
+ M's pattern and of every pair's contact support maps to a word (asserted), so the assembly of M, H and L_Q can write through it
13
+ tools/d16_14x/gen14.py calls split_header() for a body with NV > 64; run alone:
14
+ python tools/d16_bodies/gen_split.py LAW.json OUT.cuh"""
15
+ import json
16
+ import pathlib
17
+ import sys
18
+
19
+ import numpy as np
20
+
21
+ # (3a) was: sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
22
+ from diffneusim.engine import phase_b_tree as T # noqa: E402
23
+
24
+
25
+ def split_header(law):
26
+ """the split header's text for the law at path `law`, a one-line summary, and gSplitWord (dense packed entry -> split word or -1); asserts the split is exact"""
27
+ L = json.load(open(law))
28
+ nv = L["nv"]
29
+ B, own, ch = T.chains_of(L)
30
+ G = L["geoms"]
31
+ P = np.zeros((nv, nv), bool)
32
+ for c in ch:
33
+ c = sorted(c)
34
+ P[np.ix_(c, c)] = True
35
+ for pr in L["pairs"]:
36
+ c = sorted(ch[G[pr["g1"]]["body"]] | ch[G[pr["g2"]]["body"]])
37
+ P[np.ix_(c, c)] = True
38
+ E = sorted(d for d in range(nv) if T.below_wrist(B, own[d]))
39
+ assert E, "no dofs below a wrist: the split is for a body with hands"
40
+ Es = set(E)
41
+ core = [d for d in range(nv) if d not in Es]
42
+ # the chains: per wrist child, its dofs from the leaf up (deepest body first; within a body, the higher dof first)
43
+ groups = {}
44
+ for d in E:
45
+ i = own[d]
46
+ while B[B[i]["parent"]]["name"] not in T.WRIST:
47
+ i = B[i]["parent"]
48
+ groups.setdefault(i, []).append(d)
49
+
50
+ def depth(d):
51
+ i, n = own[d], 0
52
+ while i > 0:
53
+ i, n = B[i]["parent"], n + 1
54
+ return n
55
+ chains = [sorted(v, key=lambda d: (-depth(d), -d)) for _, v in sorted(groups.items())]
56
+ CL = len(chains[0])
57
+ assert all(len(c) == CL for c in chains), [len(c) for c in chains]
58
+ # exactness (PHASE_B.md section 1): no coupling across chains, none off a chain's core ancestors, a chain coupled to itself as a chain (no fill)
59
+ cpos = {d: k for k, d in enumerate(core)}
60
+ anc = []
61
+ for c in chains:
62
+ others = [d for d in E if d not in set(c)]
63
+ assert not P[np.ix_(c, others)].any(), f"chain {c} is coupled to another chain"
64
+ a = sorted({d for x in c for d in core if P[x, d]})
65
+ anc.append(a)
66
+ for x in c: # every core dof it touches is an ancestor of every dof in the chain (so the chain's update block is closed)
67
+ assert set(d for d in core if P[x, d]) <= set(a)
68
+ for k, x in enumerate(c): # leaf first: a later dof is an ancestor of an earlier one, so eliminating in order creates no fill
69
+ for y in c[k + 1:]:
70
+ assert P[x, y], f"chain {c} is not a path: {x} and {y} uncoupled"
71
+ NA = len(anc[0])
72
+ assert all(len(a) == NA for a in anc), [len(a) for a in anc]
73
+ for b in B: # the other terms of the review's check
74
+ if b.get("master_dadr", -1) >= 0:
75
+ assert b["master_dadr"] not in Es, "a coupling with its master in a finger chain"
76
+ for lim in L["limits"]:
77
+ if lim["dof"] in Es:
78
+ assert not lim["coupled"], "a coupled limit on a finger dof"
79
+ X = (pathlib.Path(law).parent / L["source"]["expanded_xml"]).read_text()
80
+ assert "<equality" not in X and "<tendon" not in X, "an equality or tendon in the expanded model"
81
+ NC, NCH = len(core), len(chains)
82
+ tri = lambda i, j: i * (i + 1) // 2 + j # noqa: E731
83
+ NTRI_C = NC * (NC + 1) // 2
84
+ upd = {}
85
+ for c, a in enumerate(anc):
86
+ al = [cpos[d] for d in a]
87
+ for ai, i in enumerate(al):
88
+ for aj, j in enumerate(al):
89
+ if j <= i:
90
+ upd.setdefault(tri(i, j), []).append(c << 16 | ai << 8 | aj)
91
+ U, Uoff = [], [0]
92
+ for e in range(NTRI_C):
93
+ U += upd.get(e, [])
94
+ Uoff.append(len(U))
95
+ ru = {}
96
+ for c, a in enumerate(anc):
97
+ for ai, d in enumerate(a):
98
+ ru.setdefault(cpos[d], []).append(c << 8 | ai)
99
+ R, Roff = [], [0]
100
+ for i in range(NC):
101
+ R += ru.get(i, [])
102
+ Roff.append(len(R))
103
+ CW = CL * (CL + 1) // 2 + NA * CL
104
+ words = NTRI_C + NCH * CW
105
+ # the map from a dense global entry to its split word (the same layout as chol_split.cuh's)
106
+ cidx = {d: (c, k) for c, ch_ in enumerate(chains) for k, d in enumerate(ch_)}
107
+ apos = [{d: a for a, d in enumerate(al)} for al in anc]
108
+ ntri = nv * (nv + 1) // 2
109
+ wmap = [-1] * ntri
110
+ for i in range(nv):
111
+ for j in range(i + 1):
112
+ if i in cpos and j in cpos:
113
+ w = tri(max(cpos[i], cpos[j]), min(cpos[i], cpos[j]))
114
+ elif i in cidx and j in cidx:
115
+ (ci, ki), (cj, kj) = cidx[i], cidx[j]
116
+ w = NTRI_C + ci * CW + tri(max(ki, kj), min(ki, kj)) if ci == cj else -1
117
+ else:
118
+ e, c_ = (i, j) if i in cidx else (j, i)
119
+ c, k = cidx[e]
120
+ w = NTRI_C + c * CW + CL * (CL + 1) // 2 + apos[c][c_] * CL + k if c_ in apos[c] else -1
121
+ wmap[tri(i, j)] = w
122
+ assert sorted(w for w in wmap if w >= 0) == list(range(words)), "every split word is one dense entry"
123
+ for i in range(nv): # the widest H (M and every pair's support) lies in the split's storage
124
+ for j in range(i + 1):
125
+ assert not P[i, j] or wmap[tri(i, j)] >= 0, f"entry ({i}, {j}) of H has no split word"
126
+ name = pathlib.Path(law).name
127
+ arr = lambda xs: ", ".join(str(int(x)) for x in xs) # noqa: E731
128
+ h = f"""#pragma once
129
+ // Generated by tools/d16_bodies/gen_split.py from {name}. Do not edit. The split factor's layout (tools/d16_bodies/PHASE_B.md section 4): the dofs below the wrists in
130
+ // {NCH} chains of {CL}, eliminated leaf first, each coupled to {NA} core ancestors; the {NC}-dof core factored dense after their Schur updates. Exact on this law (gen_split.py's asserts).
131
+ #ifndef D16_SPLIT_DEVICE
132
+ #define D16_SPLIT_DEVICE __device__
133
+ #endif
134
+ namespace d16::split {{
135
+ constexpr int NV = {nv}, NC = {NC}, NCH = {NCH}, CL = {CL}, NA = {NA};
136
+ constexpr int NTRI_C = {NTRI_C}, CEE = {CL * (CL + 1) // 2}, CW = {CW}, WORDS = {words}, NUPD = {len(U)}, NRU = {len(R)}, NTRI = {ntri};
137
+ D16_SPLIT_DEVICE const int gSplitCore[NC] = {{{arr(core)}}};
138
+ D16_SPLIT_DEVICE const int gSplitChain[NCH * CL] = {{{arr(d for c in chains for d in c)}}};
139
+ D16_SPLIT_DEVICE const int gSplitAnc[NCH * NA] = {{{arr(cpos[d] for a in anc for d in a)}}};
140
+ D16_SPLIT_DEVICE const int gSplitUpdOff[NTRI_C + 1] = {{{arr(Uoff)}}};
141
+ D16_SPLIT_DEVICE const int gSplitUpd[NUPD] = {{{arr(U)}}};
142
+ D16_SPLIT_DEVICE const int gSplitRuOff[NC + 1] = {{{arr(Roff)}}};
143
+ D16_SPLIT_DEVICE const int gSplitRu[NRU] = {{{arr(R)}}};
144
+ D16_SPLIT_DEVICE const int gSplitWord[NTRI] = {{{arr(wmap)}}};
145
+ }} // namespace d16::split
146
+ """
147
+ return h, (f"NV {nv}, core {NC}, {NCH} chains of {CL}, {NA} core ancestors each; {words} words (dense {ntri}); {len(U)} Schur updates over {len(upd)} core entries; "
148
+ f"{len(R)} rhs updates"), wmap
149
+
150
+
151
+ def main():
152
+ law, out = sys.argv[1], sys.argv[2]
153
+ h, summary, _ = split_header(law)
154
+ pathlib.Path(out).write_text(h)
155
+ print(f"{out}: {summary}")
156
+
157
+
158
+ if __name__ == "__main__":
159
+ main()