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,495 @@
1
+ // D16 engine binding (d5, 2026-11-02; tools/d16_binding/PLAN.md): the soft law's GPU control step on device tensors, with the
2
+ // signature of tools/d16/soft_capi.py's control_step_batch. The extension includes soft_capi.cpp, so Python builds the model
3
+ // handle in this library (soft_capi.Soft with LIB = this .so) and hands it to init(). Every launch is on torch's current stream
4
+ // with caller-owned buffers (graph-capturable); nothing is allocated, read back or synchronized in control_step.
5
+ #include <torch/extension.h>
6
+ #include <ATen/cuda/CUDAContext.h>
7
+
8
+ #include "soft_capi.cpp"
9
+ #include "soft/gpu/engine_launch.cuh"
10
+
11
+ namespace {
12
+ namespace E = js::soft::eng;
13
+ namespace l3 = js::soft::gpu::l3;
14
+ #define CKE(x) do { cudaError_t e_ = (x); TORCH_CHECK(e_ == cudaSuccess, #x, ": ", cudaGetErrorString(e_)); } while (0)
15
+
16
+ template <class T> T* to_dev_(const std::vector<T>& v) {
17
+ T* d = nullptr;
18
+ CKE(cudaMalloc(&d, sizeof(T) * (v.empty() ? 1 : v.size())));
19
+ if (!v.empty()) CKE(cudaMemcpy(d, v.data(), sizeof(T) * v.size(), cudaMemcpyHostToDevice));
20
+ return d;
21
+ }
22
+
23
+ // the model on the device, built once at init (never freed: one model per process)
24
+ template <class T> struct DevModel {
25
+ const T* V = nullptr; // MDK::kValues / kValuesD
26
+ const T* kd = nullptr; // kd per dof (0: no actuator)
27
+ const int* hinge_qadr = nullptr; // per dof: the hinge's qpos address, -1 for the free root's dofs
28
+ js::soft::gpu::L2Tab<T> m2{}; // L2 v2.1+'s tables in T (bindings/soft_gpu_test.cu L2TabDev)
29
+ js::soft::adj::DevCTabV<T> ctab{}; // the rows reverse's parameter views in T (B's build_ctab_views; no FP64 on the f32 path)
30
+ T h = T(0), tol = T(0);
31
+ int iterations = 0;
32
+ bool ready = false;
33
+ };
34
+ DevModel<float> g32;
35
+ DevModel<double> g64;
36
+
37
+ // v15 arm (tools/d16_binding/RESULTS.md "v15"): tail-aware dispatch. parts 16384: k_order_it (the order by rows x the previous
38
+ // solve's iterations); 32768: k_post_f32 for the kTailK order slots after the big worlds in a first launch padded with dynamic shared
39
+ // memory so that its SM holds kTailM blocks in all, the rest on a side stream (a fork-join, captured into a graph as one).
40
+ // init() sets up the side stream, the events and the padding; k_post_f32's >48 KB opt-in and max-shared carveout are set there
41
+ // for every arm (the function's attributes are process-wide).
42
+ constexpr int kOrderIt = 16384, kTailPad = 32768, kTailK = 16, kTailM = 8;
43
+ // 65536 (the review's leakage rule): the iteration key at substep 0 too, from the niter the previous launch left. In a rollout that is
44
+ // the previous control step's last substep (legitimate); in the replay benchmark it is the SAME state's substep nsub - 1 of the
45
+ // previous replay, which no rollout has: an upper bound only. Without it, substep 0 keeps production's dispatch (the row order,
46
+ // one launch) whenever kOrderIt is set.
47
+ constexpr int kArmS0 = 65536;
48
+ struct TailState {
49
+ cudaStream_t side = nullptr;
50
+ cudaEvent_t fork = nullptr, join = nullptr;
51
+ int dyn = 0; // the padded launch's dynamic shared memory (bytes)
52
+ };
53
+ TailState g_tail;
54
+ void tail_init() {
55
+ if (g_tail.side) return;
56
+ int dev = 0, sm_smem = 0, reserved = 0;
57
+ CKE(cudaGetDevice(&dev));
58
+ CKE(cudaDeviceGetAttribute(&sm_smem, cudaDevAttrMaxSharedMemoryPerMultiprocessor, dev));
59
+ CKE(cudaDeviceGetAttribute(&reserved, cudaDevAttrReservedSharedMemoryPerBlock, dev));
60
+ cudaFuncAttributes fa;
61
+ CKE(cudaFuncGetAttributes(&fa, E::k_post_f32));
62
+ constexpr int gran = 128; // the shared memory allocation unit (sm_8x)
63
+ const int st = static_cast<int>(fa.sharedSizeBytes), unit = (st + gran - 1) / gran * gran + reserved; // a normal block's share
64
+ // a padded block's share in (sm - kTailM unit, sm - (kTailM - 1) unit]: kTailM - 1 normal blocks fit beside it, kTailM do not
65
+ const int lo = sm_smem - kTailM * unit, hi = sm_smem - (kTailM - 1) * unit;
66
+ const int body = ((lo + hi) / 2 - reserved) / gran * gran; // static + dynamic, a multiple of the unit
67
+ g_tail.dyn = body - st;
68
+ TORCH_CHECK(body + reserved > lo && body + reserved <= hi && g_tail.dyn > 0, "tail padding: no share fits the window");
69
+ CKE(cudaFuncSetAttribute(E::k_post_f32, cudaFuncAttributeMaxDynamicSharedMemorySize, g_tail.dyn));
70
+ CKE(cudaFuncSetAttribute(E::k_post_f32, cudaFuncAttributePreferredSharedMemoryCarveout, cudaSharedmemCarveoutMaxShared));
71
+ int occ0 = 0, occ1 = 0;
72
+ CKE(cudaOccupancyMaxActiveBlocksPerMultiprocessor(&occ0, E::k_post_f32, 32, 0));
73
+ CKE(cudaOccupancyMaxActiveBlocksPerMultiprocessor(&occ1, E::k_post_f32, 32, g_tail.dyn));
74
+ TORCH_CHECK(occ0 == 16 && occ1 == 1, "tail padding: k_post_f32 occupancy ", occ0, " / padded ", occ1, " (expected 16 / 1)");
75
+ CKE(cudaStreamCreateWithFlags(&g_tail.side, cudaStreamNonBlocking));
76
+ CKE(cudaEventCreateWithFlags(&g_tail.fork, cudaEventDisableTiming));
77
+ CKE(cudaEventCreateWithFlags(&g_tail.join, cudaEventDisableTiming));
78
+ }
79
+
80
+ template <class T> void build(DevModel<T>& g, const js::soft::SoftModel& sm, const float* rbound) {
81
+ TORCH_CHECK(sm.nv == E::MDK::NV && sm.nq == E::MDK::NQ && static_cast<int>(sm.bodies.size()) == E::MDK::NB &&
82
+ static_cast<int>(sm.actuators.size()) == E::MDK::NU, "the law is not the generated model");
83
+ std::vector<T> V(E::MDK::NVALS);
84
+ for (int i = 0; i < E::MDK::NVALS; ++i) V[i] = sizeof(T) == 4 ? T(E::MDK::kValues[i]) : T(E::MDK::kValuesD[i]);
85
+ g.V = to_dev_(V);
86
+ std::vector<T> kd(sm.nv, T(0));
87
+ for (const js::soft::SoftActuator& a : sm.actuators) kd[a.dof] = T(a.kd);
88
+ g.kd = to_dev_(kd);
89
+ std::vector<int> hq(sm.nv, -1);
90
+ for (const js::soft::SoftBody& b : sm.bodies) if (b.jnt_type == js::soft::kJntHinge) hq[b.dadr] = b.qadr;
91
+ g.hinge_qadr = to_dev_(hq);
92
+ // L2's tables in T (bindings/soft_gpu_test.cu's L2TabDev at 45c87412: every parameter precomputed on the host
93
+ // from the CPU law in double, then cast, so the f32 kernel runs no FP64 instruction)
94
+ js::soft::gpu::L2Tab<T>& m = g.m2;
95
+ m.ng = static_cast<int>(sm.geoms.size()); m.np = static_cast<int>(sm.pairs.size()); m.nj = static_cast<int>(sm.joints.size());
96
+ m.nv = sm.nv; m.nb = static_cast<int>(sm.bodies.size()); m.impratio = static_cast<T>(sm.impratio);
97
+ TORCH_CHECK(m.ng <= E::kV2NG && m.np <= E::kV2NP && m.nv <= 64 && m.nb <= 255 && m.ng <= 256, "L2: the model exceeds the compiled capacities");
98
+ std::vector<unsigned long long> mask(m.nb, 0ULL);
99
+ std::vector<unsigned char> trans(m.nv, 0), dbody(m.nv, 0);
100
+ for (int b = 1; b < m.nb; ++b) {
101
+ const js::soft::SoftBody& bd = sm.bodies[b];
102
+ unsigned long long mk = bd.parent >= 0 ? mask[bd.parent] : 0ULL;
103
+ if (bd.jnt_type == js::soft::kJntFree) {
104
+ for (int k = 0; k < 6; ++k) { mk |= 1ULL << (bd.dadr + k); dbody[bd.dadr + k] = static_cast<unsigned char>(b); }
105
+ for (int k = 0; k < 3; ++k) trans[bd.dadr + k] = 1;
106
+ } else if (bd.jnt_type == js::soft::kJntHinge) {
107
+ mk |= 1ULL << bd.dadr; dbody[bd.dadr] = static_cast<unsigned char>(b);
108
+ }
109
+ mask[b] = mk;
110
+ }
111
+ std::vector<int> gbody(m.ng), gtype(m.ng);
112
+ std::vector<T> gpq(7 * m.ng), gsize(3 * m.ng);
113
+ for (int gi = 0; gi < m.ng; ++gi) {
114
+ const js::soft::SoftGeom& sg = sm.geoms[gi];
115
+ gbody[gi] = sg.body; gtype[gi] = sg.type;
116
+ for (int k = 0; k < 3; ++k) { gpq[7 * gi + k] = static_cast<T>(sg.pos[k]); gsize[3 * gi + k] = static_cast<T>(sg.size[k]); }
117
+ for (int k = 0; k < 4; ++k) gpq[7 * gi + 3 + k] = static_cast<T>(sg.quat[k]);
118
+ }
119
+ std::vector<unsigned> pgeo(m.np);
120
+ std::vector<T> pthr(m.np), preach(m.np), pmargin(m.np), pmu0(m.np), pK(m.np), pB(m.np), pimp(5 * m.np), ptran(m.np);
121
+ std::vector<unsigned long long> pplus(m.np), pminus(m.np);
122
+ for (int i = 0; i < m.np; ++i) {
123
+ const js::soft::SoftPair& pr = sm.pairs[i];
124
+ TORCH_CHECK(pr.g1 < 256 && pr.g2 < 256 && (pr.condim == 1 || pr.condim == 3), "L2: pair fields");
125
+ pgeo[i] = static_cast<unsigned>(pr.g1) | static_cast<unsigned>(pr.g2) << 8 | static_cast<unsigned>(pr.condim) << 16 |
126
+ (pr.foot >= 0 ? 1u : 0u) << 18;
127
+ const T reach = static_cast<T>(pr.margin + pr.gap); // v2's broadphase arithmetic, in T
128
+ if (sm.geoms[pr.g1].type == 0) {
129
+ pthr[i] = (static_cast<T>(rbound[pr.g2]) + reach) * T(1.0001) + T(1e-6);
130
+ } else {
131
+ const T rb = static_cast<T>(rbound[pr.g1]) + static_cast<T>(rbound[pr.g2]) + reach;
132
+ pthr[i] = rb * rb * T(1.0002) + T(1e-12);
133
+ }
134
+ preach[i] = static_cast<T>(pr.margin + pr.gap);
135
+ pmargin[i] = static_cast<T>(pr.margin);
136
+ pmu0[i] = static_cast<T>(pr.friction[0]);
137
+ const js::soft::SolParam sp = js::soft::sol_param(pr.solref, pr.solimp, sm.timestep);
138
+ const js::soft::KB kb = js::soft::stiffness_damping(sp, false);
139
+ pK[i] = static_cast<T>(kb.K); pB[i] = static_cast<T>(kb.B);
140
+ for (int k = 0; k < 5; ++k) pimp[5 * i + k] = static_cast<T>(sp.imp[k]);
141
+ const int b1 = sm.geoms[pr.g1].body, b2 = sm.geoms[pr.g2].body;
142
+ ptran[i] = static_cast<T>(sm.bodies[b1].invweight0[0] + sm.bodies[b2].invweight0[0]);
143
+ pplus[i] = mask[b2] & ~mask[b1]; pminus[i] = mask[b1] & ~mask[b2];
144
+ }
145
+ std::vector<int> jdof(m.nj), jqadr(m.nj);
146
+ std::vector<unsigned char> jlim(m.nj);
147
+ std::vector<T> jrange(2 * m.nj), jmargin(m.nj), jK(m.nj), jB(m.nj), jimp(5 * m.nj), jinvw(m.nj);
148
+ for (int j = 0; j < m.nj; ++j) {
149
+ const js::soft::SoftJoint& jt = sm.joints[j];
150
+ jdof[j] = jt.dof; jqadr[j] = jt.qadr; jlim[j] = jt.limited ? 1 : 0;
151
+ jrange[2 * j] = static_cast<T>(jt.range[0]); jrange[2 * j + 1] = static_cast<T>(jt.range[1]);
152
+ jmargin[j] = static_cast<T>(jt.margin);
153
+ const js::soft::SolParam sp = js::soft::sol_param(jt.solref, jt.solimp, sm.timestep);
154
+ const js::soft::KB kb = js::soft::stiffness_damping(sp, false);
155
+ jK[j] = static_cast<T>(kb.K); jB[j] = static_cast<T>(kb.B);
156
+ for (int k = 0; k < 5; ++k) jimp[5 * j + k] = static_cast<T>(sp.imp[k]);
157
+ jinvw[j] = static_cast<T>(sm.dof_invweight0[jt.dof]);
158
+ }
159
+ m.geom_body = to_dev_(gbody); m.geom_type = to_dev_(gtype); m.geom_pq = to_dev_(gpq); m.geom_size = to_dev_(gsize);
160
+ m.pr_geo = to_dev_(pgeo); m.pr_thr = to_dev_(pthr); m.pr_reach = to_dev_(preach); m.pr_margin = to_dev_(pmargin);
161
+ m.pr_mu0 = to_dev_(pmu0); m.pr_K = to_dev_(pK); m.pr_B = to_dev_(pB); m.pr_imp = to_dev_(pimp); m.pr_tran = to_dev_(ptran);
162
+ m.pr_plus = to_dev_(pplus); m.pr_minus = to_dev_(pminus);
163
+ m.jt_dof = to_dev_(jdof); m.jt_qadr = to_dev_(jqadr); m.jt_limited = to_dev_(jlim); m.jt_range = to_dev_(jrange);
164
+ m.jt_margin = to_dev_(jmargin); m.jt_K = to_dev_(jK); m.jt_B = to_dev_(jB); m.jt_imp = to_dev_(jimp); m.jt_invw = to_dev_(jinvw);
165
+ m.dof_trans = to_dev_(trans); m.dof_body = to_dev_(dbody);
166
+ // the adjoint's structural conditions, checked here so its kernel carries no device assert (JS_DEVICE_ASSERT): every pair is a
167
+ // geom-type pair collide() / collide_reverse handle, and a plane (geom a) sits on a static body (no joint up its chain)
168
+ for (const js::soft::SoftPair& pr : sm.pairs) {
169
+ const int t1 = sm.geoms[pr.g1].type, t2 = sm.geoms[pr.g2].type;
170
+ TORCH_CHECK(js::soft::collide_handles(t1, t2), "a geom-type pair collide() / collide_reverse do not handle");
171
+ if (t1 == 0)
172
+ for (int b = sm.geoms[pr.g1].body; b > 0; b = sm.bodies[b].parent)
173
+ TORCH_CHECK(sm.bodies[b].jnt_type == -1, "a plane on a moving body (collide_reverse differentiates static planes only)");
174
+ }
175
+ { // B's rows tables (tools/d16_adj/megakernel_time.cu, adj_ref.cpp soft_rows_export_model: body_iw = invweight0[0])
176
+ std::vector<double> biw(sm.bodies.size());
177
+ for (size_t b = 0; b < sm.bodies.size(); ++b) biw[b] = sm.bodies[b].invweight0[0];
178
+ const js::soft::adj::CTabViews<T> tv = js::soft::adj::build_ctab_views<T>(sm.geoms, sm.pairs, sm.joints, sm.actuators,
179
+ sm.dof_invweight0, biw, sm.timestep);
180
+ g.ctab = js::soft::adj::DevCTabV<T>{to_dev_(tv.pv), to_dev_(tv.gv), to_dev_(tv.jv), to_dev_(tv.av), static_cast<int>(sm.joints.size()),
181
+ static_cast<int>(sm.actuators.size()), sm.nv, static_cast<T>(sm.impratio)};
182
+ }
183
+ g.h = T(sm.timestep); g.tol = T(sm.tolerance); g.iterations = sm.iterations;
184
+ g.ready = true;
185
+ }
186
+
187
+ void init(int64_t handle, torch::Tensor rbound) {
188
+ TORCH_CHECK(rbound.device().is_cpu() && rbound.dtype() == torch::kFloat32 && rbound.is_contiguous(), "rbound: cpu float32");
189
+ const js::soft::SoftModel& sm = act_model(reinterpret_cast<void*>(handle)).sm;
190
+ build(g32, sm, rbound.data_ptr<float>());
191
+ build(g64, sm, rbound.data_ptr<float>());
192
+ tail_init();
193
+ }
194
+
195
+ void chk(const torch::Tensor& t, at::ScalarType st, std::vector<int64_t> shape, const char* name) {
196
+ TORCH_CHECK(t.is_cuda() && t.scalar_type() == st && t.is_contiguous(), name, ": a contiguous CUDA tensor of the right dtype");
197
+ TORCH_CHECK(t.sizes().vec() == shape, name, ": shape ", t.sizes(), " expected ", c10::IntArrayRef(shape));
198
+ }
199
+
200
+ // one control step for n worlds. State ping-pong (substep 0: in -> scr, 1: scr -> out, 2: out -> scr, 3: scr -> out), warm
201
+ // likewise; hand / nefc / k_post's per-world outputs are scratch; flags [n] u32 are OR-ed (zero them per iteration);
202
+ // stats [n, nsub, 6]; frames [n, nbt, ...] at the output state.
203
+ constexpr int kSorted = 16, kAllBig = 32; // control_step's dispatch bits (parts)
204
+ // 64: TIMING ONLY, skip the big kernel's launch with the order kept (valid only when no world exceeds NR: a world over NR
205
+ // then runs on the fast kernel, which flags it overflow), to time the empty big launch the production order pays (v9)
206
+ constexpr int kNoBig = 64;
207
+ // 128: TIMING ONLY, skip the fast k_post launch (the order and the big launch kept), for the graph-prefix split of the forward
208
+ // (k_pre, k_order, the big launch, k_post, tail, frames); the next substep's k_pre then reads the ping-pong buffers as left
209
+ constexpr int kNoPost = 128;
210
+
211
+ template <class T>
212
+ void step_t(const DevModel<T>& g, torch::Tensor qpos, torch::Tensor qvel, torch::Tensor warm, torch::Tensor ctrl, torch::Tensor fric,
213
+ torch::Tensor oq, torch::Tensor ov, torch::Tensor ow, torch::Tensor sq, torch::Tensor sv, torch::Tensor sw, torch::Tensor hand,
214
+ torch::Tensor nefc, torch::Tensor a_adv, torch::Tensor qfrc_c, torch::Tensor LH, torch::Tensor LQ, torch::Tensor zone,
215
+ torch::Tensor niter, torch::Tensor kflags, torch::Tensor nls, torch::Tensor nfact, torch::Tensor cycles, torch::Tensor flags,
216
+ torch::Tensor stats, torch::Tensor bodies, torch::Tensor xpos, torch::Tensor xquat, torch::Tensor xvel, torch::Tensor xangvel,
217
+ #ifdef D16_G1_COMDR
218
+ torch::Tensor order, torch::Tensor nbig, torch::Tensor tape, int nsub, int parts, torch::Tensor ipo, int ipo_body) {
219
+ #else
220
+ torch::Tensor order, torch::Tensor nbig, torch::Tensor tape, int nsub, int parts) {
221
+ #endif
222
+ TORCH_CHECK(g.ready, "init() first");
223
+ TORCH_CHECK(nsub % 2 == 0, "the ping-pong ends in the output buffers for an even substep count");
224
+ const int64_t n = qpos.size(0);
225
+ const auto st = sizeof(T) == 4 ? torch::kFloat32 : torch::kFloat64;
226
+ using TN = std::pair<torch::Tensor*, const char*>; // typed lists (nvcc's front end does not deduce a mixed braced list)
227
+ for (const TN& p : std::initializer_list<TN>{{&qpos, "qpos"}, {&oq, "out qpos"}, {&sq, "scratch qpos"}}) chk(*p.first, st, {n, E::MDK::NQ}, p.second);
228
+ for (const TN& p : std::initializer_list<TN>{{&qvel, "qvel"}, {&warm, "warm"}, {&ov, "out qvel"}, {&ow, "out warm"}, {&sv, "scratch qvel"},
229
+ {&sw, "scratch warm"}, {&a_adv, "a_adv"}})
230
+ chk(*p.first, st, {n, E::NV}, p.second);
231
+ chk(ctrl, st, {n, E::MDK::NU}, "ctrl"); chk(fric, st, {n}, "friction"); chk(hand, st, {n, E::HL.words}, "hand");
232
+ #ifdef D16_G1_COMDR
233
+ chk(ipo, st, {n, 3}, "ipo (COMDR: the worlds' anchor CoM offsets)");
234
+ TORCH_CHECK(ipo_body >= 1 && ipo_body < E::MDK::NB, "ipo_body: a moving body");
235
+ #endif
236
+ // k_post's dense test outputs (LH, LQ, zone, qfrc_c): optional since the v3d (the tape carries them); empty tensors = null
237
+ if (qfrc_c.numel() > 0) chk(qfrc_c, st, {n, E::NV}, "qfrc_c");
238
+ if (LH.numel() > 0) chk(LH, st, {n, E::NV * (E::NV + 1) / 2}, "LH");
239
+ if (LQ.numel() > 0) chk(LQ, st, {n, E::NV * (E::NV + 1) / 2}, "LQ");
240
+ if (zone.numel() > 0) chk(zone, torch::kInt32, {n, E::kZoneWords}, "zone");
241
+ for (const TN& p : std::initializer_list<TN>{{&nefc, "nefc"}, {&niter, "niter"}, {&kflags, "kflags"}, {&nls, "nls"}, {&nfact, "nfact"},
242
+ {&flags, "flags"}})
243
+ chk(*p.first, torch::kInt32, {n}, p.second);
244
+ chk(order, torch::kInt32, {n}, "order");
245
+ TORCH_CHECK(nbig.is_cuda() && nbig.scalar_type() == torch::kInt32 && nbig.is_contiguous() && nbig.dim() == 1, "nbig: int32 [chunks]");
246
+ // the tape: [n, nsub, TL.words] in T (k_post every word but POSE, k_pre the POSE block), or an empty tensor (no tape)
247
+ const bool taped = tape.numel() > 0;
248
+ if (taped) chk(tape, st, {n, nsub, E::TL.words}, "tape");
249
+ const long long tstride = static_cast<long long>(nsub) * E::TL.words;
250
+ TORCH_CHECK(l3::kpost_tape_ok(taped ? tape.data_ptr<T>() : nullptr, tstride, E::NV, E::NC, E::NRH),
251
+ "the tape's world stride is below the record's words (C's kpost_tape_ok: the launcher's check, no device assert)");
252
+ // cycles: [n] (the last substep's k_post cycles per world) or [nsub, n] (every substep's: row k = substep k; host offsets only)
253
+ const bool cyc_sub = cycles.dim() == 2;
254
+ if (cyc_sub) chk(cycles, torch::kInt64, {nsub, n}, "cycles"); else chk(cycles, torch::kInt64, {n}, "cycles");
255
+ chk(stats, torch::kInt32, {n, nsub, E::kStatW}, "stats");
256
+ const int64_t nbt = bodies.size(0);
257
+ chk(bodies, torch::kInt32, {nbt}, "bodies");
258
+ chk(xpos, st, {n, nbt, 3}, "xpos"); chk(xquat, st, {n, nbt, 4}, "xquat"); chk(xvel, st, {n, nbt, 3}, "xvel");
259
+ chk(xangvel, st, {n, nbt, 3}, "xangvel");
260
+ cudaStream_t s = at::cuda::getCurrentCUDAStream();
261
+ const unsigned nw = static_cast<unsigned>(n);
262
+ T *bq[2] = {sq.data_ptr<T>(), oq.data_ptr<T>()}, *bv[2] = {sv.data_ptr<T>(), ov.data_ptr<T>()}, *bw[2] = {sw.data_ptr<T>(), ow.data_ptr<T>()};
263
+ const T *iq = qpos.data_ptr<T>(), *iv = qvel.data_ptr<T>(), *iw = warm.data_ptr<T>();
264
+ // v8 (the review's lever after the dump test): parts bits 8-11 = the world chunks per substep (0 or 1: one launch set over
265
+ // all n worlds). With nch > 1, k_pre, the order, k_post and the tail run per chunk of worlds [n c / nch, n (c + 1) / nch), so
266
+ // a chunk's hands are still in L2 when its k_post reads them. Every per-world array is offset to the chunk's first world and
267
+ // each chunk has its own nbig slot; a world's computation does not depend on the chunking (the outputs are bitwise the same).
268
+ const int nch = std::max(1, (parts >> 8) & 15);
269
+ TORCH_CHECK(nbig.numel() >= nch, "nbig: one slot per world chunk");
270
+ if (parts & (kOrderIt | kTailPad))
271
+ TORCH_CHECK((parts & kSorted) && !(parts & kAllBig), "v15 arms: on the production order only (parts 16, not 32)");
272
+ if (parts & kTailPad)
273
+ TORCH_CHECK(sizeof(T) == 4 && nch == 1 && n > kTailK && !(parts & kNoPost), "v15 padded launch: f32, one chunk, n > ", kTailK);
274
+ if (parts & kArmS0) TORCH_CHECK(parts & kOrderIt, "v15: kArmS0 extends the iteration key to substep 0 (needs 16384)");
275
+ constexpr int NQ = E::MDK::NQ, NV = E::NV, NU = E::MDK::NU, NTRI = E::NV * (E::NV + 1) / 2;
276
+ for (int k = 0; k < nsub; ++k) {
277
+ T *q1 = bq[k & 1], *v1 = bv[k & 1], *w1 = bw[k & 1];
278
+ T* rec_s = taped ? tape.data_ptr<T>() + static_cast<size_t>(k) * E::TL.words : nullptr; // substep k's record of world 0
279
+ for (int c = 0; c < nch; ++c) {
280
+ const int64_t w0 = n * c / nch, nc = n * (c + 1) / nch - w0;
281
+ if (nc == 0) continue;
282
+ const unsigned nwc = static_cast<unsigned>(nc);
283
+ T* rec_c = taped ? rec_s + w0 * tstride : nullptr;
284
+ T* hand_c = hand.data_ptr<T>() + w0 * E::HL.words;
285
+ int* nefc_c = nefc.data_ptr<int>() + w0;
286
+ const T *iqc = iq + w0 * NQ, *ivc = iv + w0 * NV, *iwc = iw + w0 * NV;
287
+ #ifdef D16_G1_COMDR
288
+ if (parts & 1) E::kpre_kernel<T><<<nwc, 32, 0, s>>>(g.V, g.m2, E::HL, static_cast<int>(nc), iqc, ivc, ctrl.data_ptr<T>() + w0 * NU,
289
+ fric.data_ptr<T>() + w0, hand_c, nefc_c, taped ? rec_c + E::TL.pose : nullptr, tstride, nullptr,
290
+ ipo.data_ptr<T>() + w0 * 3, ipo_body);
291
+ #else
292
+ if (parts & 1) E::kpre_kernel<T><<<nwc, 32, 0, s>>>(g.V, g.m2, E::HL, static_cast<int>(nc), iqc, ivc, ctrl.data_ptr<T>() + w0 * NU,
293
+ fric.data_ptr<T>() + w0, hand_c, nefc_c, taped ? rec_c + E::TL.pose : nullptr, tstride, nullptr);
294
+ #endif
295
+ l3::Args<T> a{};
296
+ a.nw = static_cast<int>(nc); a.nq = NQ; a.hand = hand_c; a.nefc = nefc_c;
297
+ a.qpos = iqc; a.qvel = ivc; a.warm = iwc; a.kd = g.kd; a.hinge_qadr = g.hinge_qadr; a.h = g.h; a.tol = g.tol;
298
+ a.iterations = g.iterations; a.order = nullptr;
299
+ a.a_star = w1 + w0 * NV; a.a_adv = a_adv.data_ptr<T>() + w0 * NV; a.qvel1 = v1 + w0 * NV; a.qpos1 = q1 + w0 * NQ;
300
+ a.qfrc_c = qfrc_c.numel() ? qfrc_c.data_ptr<T>() + w0 * NV : nullptr;
301
+ a.LH = LH.numel() ? LH.data_ptr<T>() + w0 * NTRI : nullptr; a.LQ = LQ.numel() ? LQ.data_ptr<T>() + w0 * NTRI : nullptr;
302
+ a.zone = zone.numel() ? reinterpret_cast<unsigned*>(zone.data_ptr<int>()) + w0 * E::kZoneWords : nullptr; a.zone_words = E::kZoneWords;
303
+ a.niter = niter.data_ptr<int>() + w0; a.flags = kflags.data_ptr<int>() + w0; a.nls = nls.data_ptr<int>() + w0;
304
+ a.nfact = nfact.data_ptr<int>() + w0;
305
+ a.cycles = reinterpret_cast<long long*>(cycles.data_ptr<int64_t>()) + (cyc_sub ? static_cast<int64_t>(k) * n : 0) + w0;
306
+ a.prof = nullptr;
307
+ a.tape = rec_c; a.tape_stride = taped ? tstride : 0;
308
+ if (parts & 2) {
309
+ // parts 16: the row-count order with the big kernel for the worlds over NR rows (production); 32: every world on the big
310
+ // kernel (its positive control); neither: identity order, all on the fast kernel (v0, a world over NR flagged overflow)
311
+ const bool sorted = parts & (kSorted | kAllBig);
312
+ // v15: the iteration key and the padded launch; at substep 0 with the iteration key only under kArmS0 (else production's)
313
+ const bool it_key = (parts & kOrderIt) && (k > 0 || (parts & kArmS0));
314
+ const bool pad = (parts & kTailPad) && (it_key || !(parts & kOrderIt));
315
+ int* ord = sorted ? order.data_ptr<int>() + w0 : nullptr;
316
+ int* nb = nbig.data_ptr<int>() + c;
317
+ if (sorted) {
318
+ if (it_key) E::k_order_it<<<1, 1024, 0, s>>>(static_cast<int>(nc), nefc_c, niter.data_ptr<int>() + w0, E::NR, ord, nb);
319
+ else E::k_order<<<1, 1024, 0, s>>>(static_cast<int>(nc), nefc_c, (parts & kAllBig) ? -1 : E::NR, ord, nb);
320
+ if (!(parts & kNoBig)) {
321
+ if constexpr (sizeof(T) == 4) E::k_post_big_f32<<<nwc, 32, 0, s>>>(a, ord, nb); else E::k_post_big_f64<<<nwc, 32, 0, s>>>(a, ord, nb);
322
+ }
323
+ }
324
+ if (!(parts & kNoPost)) {
325
+ if constexpr (sizeof(T) == 4) {
326
+ if (pad) { // v15: the heavy slots [nbig, nbig + K) first, padded; the rest beside them on the side stream
327
+ CKE(cudaEventRecord(g_tail.fork, s));
328
+ E::k_post_f32<<<kTailK, 32, g_tail.dyn, s>>>(a, ord, nb);
329
+ CKE(cudaStreamWaitEvent(g_tail.side, g_tail.fork, 0));
330
+ l3::Args<T> a2 = a;
331
+ a2.nw = static_cast<int>(nc) - kTailK; // with order + K: slots nbig + K .. nc - 1 (a.nw enters only fast_world)
332
+ E::k_post_f32<<<nwc - kTailK, 32, 0, g_tail.side>>>(a2, ord + kTailK, nb);
333
+ CKE(cudaEventRecord(g_tail.join, g_tail.side));
334
+ CKE(cudaStreamWaitEvent(s, g_tail.join, 0));
335
+ } else {
336
+ E::k_post_f32<<<nwc, 32, 0, s>>>(a, ord, nb);
337
+ }
338
+ } else {
339
+ E::k_post_f64<<<nwc, 32, 0, s>>>(a, ord, nb);
340
+ }
341
+ }
342
+ }
343
+ if (parts & 4) E::k_substep_tail<T><<<(nwc + 127) / 128, 128, 0, s>>>(static_cast<int>(nc), hand_c, niter.data_ptr<int>() + w0,
344
+ kflags.data_ptr<int>() + w0, reinterpret_cast<uint32_t*>(flags.data_ptr<int>()) + w0,
345
+ stats.data_ptr<int>() + w0 * nsub * E::kStatW, k, nsub);
346
+ }
347
+ iq = q1; iv = v1; iw = w1;
348
+ }
349
+ if (parts & 8) E::k_frames<T><<<nw, 32, 0, s>>>(g.V, static_cast<int>(n), oq.data_ptr<T>(), ov.data_ptr<T>(), static_cast<int>(nbt), bodies.data_ptr<int>(),
350
+ xpos.data_ptr<T>(), xquat.data_ptr<T>(), xvel.data_ptr<T>(), xangvel.data_ptr<T>());
351
+ CKE(cudaGetLastError());
352
+ }
353
+
354
+ void control_step(torch::Tensor qpos, torch::Tensor qvel, torch::Tensor warm, torch::Tensor ctrl, torch::Tensor fric, torch::Tensor oq,
355
+ torch::Tensor ov, torch::Tensor ow, torch::Tensor sq, torch::Tensor sv, torch::Tensor sw, torch::Tensor hand, torch::Tensor nefc,
356
+ torch::Tensor a_adv, torch::Tensor qfrc_c, torch::Tensor LH, torch::Tensor LQ, torch::Tensor zone, torch::Tensor niter,
357
+ torch::Tensor kflags, torch::Tensor nls, torch::Tensor nfact, torch::Tensor cycles, torch::Tensor flags, torch::Tensor stats,
358
+ #ifdef D16_G1_COMDR
359
+ torch::Tensor bodies, torch::Tensor xpos, torch::Tensor xquat, torch::Tensor xvel, torch::Tensor xangvel, torch::Tensor order, torch::Tensor nbig, torch::Tensor tape, int64_t nsub, int64_t parts,
360
+ torch::Tensor ipo, int64_t ipo_body) {
361
+ if (qpos.scalar_type() == torch::kFloat32)
362
+ step_t<float>(g32, qpos, qvel, warm, ctrl, fric, oq, ov, ow, sq, sv, sw, hand, nefc, a_adv, qfrc_c, LH, LQ, zone, niter, kflags, nls, nfact,
363
+ cycles, flags, stats, bodies, xpos, xquat, xvel, xangvel, order, nbig, tape, static_cast<int>(nsub), static_cast<int>(parts),
364
+ ipo, static_cast<int>(ipo_body));
365
+ else
366
+ step_t<double>(g64, qpos, qvel, warm, ctrl, fric, oq, ov, ow, sq, sv, sw, hand, nefc, a_adv, qfrc_c, LH, LQ, zone, niter, kflags, nls,
367
+ nfact, cycles, flags, stats, bodies, xpos, xquat, xvel, xangvel, order, nbig, tape, static_cast<int>(nsub), static_cast<int>(parts),
368
+ ipo, static_cast<int>(ipo_body));
369
+ }
370
+ #else
371
+ torch::Tensor bodies, torch::Tensor xpos, torch::Tensor xquat, torch::Tensor xvel, torch::Tensor xangvel, torch::Tensor order, torch::Tensor nbig, torch::Tensor tape, int64_t nsub, int64_t parts) {
372
+ if (qpos.scalar_type() == torch::kFloat32)
373
+ step_t<float>(g32, qpos, qvel, warm, ctrl, fric, oq, ov, ow, sq, sv, sw, hand, nefc, a_adv, qfrc_c, LH, LQ, zone, niter, kflags, nls, nfact,
374
+ cycles, flags, stats, bodies, xpos, xquat, xvel, xangvel, order, nbig, tape, static_cast<int>(nsub), static_cast<int>(parts));
375
+ else
376
+ step_t<double>(g64, qpos, qvel, warm, ctrl, fric, oq, ov, ow, sq, sv, sw, hand, nefc, a_adv, qfrc_c, LH, LQ, zone, niter, kflags, nls,
377
+ nfact, cycles, flags, stats, bodies, xpos, xquat, xvel, xangvel, order, nbig, tape, static_cast<int>(nsub), static_cast<int>(parts));
378
+ }
379
+ #endif
380
+
381
+ // one control step's adjoint for n worlds (d5's shell k_adjoint_step + B's RowsBFactory), reading the tape the forward wrote:
382
+ // tape [n, nsub, TL.words]; q_out [n, 36] / v_out [n, 35] the forward's output state (for the output frames' pull-back); wq / wv
383
+ // [n, 35] the cotangents of the output state (q in the tangent at q_out); foot [n] f64 the worlds' foot friction (-1: the
384
+ // pairs' own); the output frames' cotangents [n, 32, 3] each, or empty tensors; q_bar / v_bar [n, 35], u_bar [n, 29] (written),
385
+ // aflags [n] u32 (written: the shell's and the rows' failure bits), cycles [n] i64 or empty.
386
+ template <class T>
387
+ void adjoint_t(const DevModel<T>& g, torch::Tensor tape, torch::Tensor q_out, torch::Tensor v_out, torch::Tensor wq, torch::Tensor wv,
388
+ torch::Tensor foot, torch::Tensor xpos_bar, torch::Tensor xrot_bar, torch::Tensor vb_bar, torch::Tensor wb_bar,
389
+ #ifdef D16_G1_COMDR
390
+ torch::Tensor q_bar, torch::Tensor v_bar, torch::Tensor u_bar, torch::Tensor aflags, torch::Tensor cycles, int nsub,
391
+ torch::Tensor ipo, int ipo_body) {
392
+ #else
393
+ torch::Tensor q_bar, torch::Tensor v_bar, torch::Tensor u_bar, torch::Tensor aflags, torch::Tensor cycles, int nsub) {
394
+ #endif
395
+ namespace A = js::soft::adj;
396
+ TORCH_CHECK(g.ready, "init() first");
397
+ const int64_t n = tape.size(0);
398
+ const auto st = sizeof(T) == 4 ? torch::kFloat32 : torch::kFloat64;
399
+ chk(tape, st, {n, nsub, E::TL.words}, "tape"); chk(q_out, st, {n, E::MDK::NQ}, "q_out"); chk(v_out, st, {n, E::NV}, "v_out");
400
+ chk(wq, st, {n, E::NV}, "wq"); chk(wv, st, {n, E::NV}, "wv"); chk(foot, torch::kFloat64, {n}, "foot (f64)");
401
+ chk(q_bar, st, {n, E::NV}, "q_bar"); chk(v_bar, st, {n, E::NV}, "v_bar"); chk(u_bar, st, {n, E::MDK::NU}, "u_bar");
402
+ chk(aflags, torch::kInt32, {n}, "aflags");
403
+ #ifdef D16_G1_COMDR
404
+ chk(ipo, st, {n, 3}, "ipo (COMDR: the forward's anchor CoM offsets)");
405
+ TORCH_CHECK(ipo_body >= 1 && ipo_body < E::MDK::NB, "ipo_body: a moving body");
406
+ #endif
407
+ const T* ob[4] = {nullptr, nullptr, nullptr, nullptr};
408
+ const torch::Tensor* obt[4] = {&xpos_bar, &xrot_bar, &vb_bar, &wb_bar};
409
+ for (int k = 0; k < 4; ++k)
410
+ if (obt[k]->numel() > 0) { chk(*obt[k], st, {n, A::kNB, 3}, "output frame cotangent"); ob[k] = obt[k]->data_ptr<T>(); }
411
+ long long* cyc = nullptr;
412
+ if (cycles.numel() > 0) { chk(cycles, torch::kInt64, {n}, "cycles"); cyc = reinterpret_cast<long long*>(cycles.data_ptr<int64_t>()); }
413
+ using Fac = A::RowsBFactory<T, A::GenTab<T>, A::DevCTabV<T>>;
414
+ const Fac rows{A::GenTab<T>{g.V}, g.ctab, E::TL, foot.data_ptr<double>()};
415
+ cudaStream_t s = at::cuda::getCurrentCUDAStream();
416
+ A::k_adjoint_step<T, Fac><<<static_cast<unsigned>(n), 32, A::adj_shell_smem<T>(), s>>>(
417
+ g.V, g.kd, tape.data_ptr<T>(), E::TL, nsub, g.h, static_cast<int>(n), q_out.data_ptr<T>(), v_out.data_ptr<T>(), wq.data_ptr<T>(),
418
+ wv.data_ptr<T>(), ob[0], ob[1], ob[2], ob[3], rows, q_bar.data_ptr<T>(), v_bar.data_ptr<T>(), u_bar.data_ptr<T>(),
419
+ #ifdef D16_G1_COMDR
420
+ reinterpret_cast<uint32_t*>(aflags.data_ptr<int>()), nullptr, cyc, ipo.data_ptr<T>(), ipo_body);
421
+ #else
422
+ reinterpret_cast<uint32_t*>(aflags.data_ptr<int>()), nullptr, cyc);
423
+ #endif
424
+ CKE(cudaGetLastError());
425
+ }
426
+
427
+ void adjoint(torch::Tensor tape, torch::Tensor q_out, torch::Tensor v_out, torch::Tensor wq, torch::Tensor wv, torch::Tensor foot,
428
+ torch::Tensor xpos_bar, torch::Tensor xrot_bar, torch::Tensor vb_bar, torch::Tensor wb_bar, torch::Tensor q_bar,
429
+ #ifdef D16_G1_COMDR
430
+ torch::Tensor v_bar, torch::Tensor u_bar, torch::Tensor aflags, torch::Tensor cycles, int64_t nsub, torch::Tensor ipo,
431
+ int64_t ipo_body) {
432
+ if (tape.scalar_type() == torch::kFloat32)
433
+ adjoint_t<float>(g32, tape, q_out, v_out, wq, wv, foot, xpos_bar, xrot_bar, vb_bar, wb_bar, q_bar, v_bar, u_bar, aflags, cycles,
434
+ static_cast<int>(nsub), ipo, static_cast<int>(ipo_body));
435
+ else
436
+ adjoint_t<double>(g64, tape, q_out, v_out, wq, wv, foot, xpos_bar, xrot_bar, vb_bar, wb_bar, q_bar, v_bar, u_bar, aflags, cycles,
437
+ static_cast<int>(nsub), ipo, static_cast<int>(ipo_body));
438
+ }
439
+ #else
440
+ torch::Tensor v_bar, torch::Tensor u_bar, torch::Tensor aflags, torch::Tensor cycles, int64_t nsub) {
441
+ if (tape.scalar_type() == torch::kFloat32)
442
+ adjoint_t<float>(g32, tape, q_out, v_out, wq, wv, foot, xpos_bar, xrot_bar, vb_bar, wb_bar, q_bar, v_bar, u_bar, aflags, cycles,
443
+ static_cast<int>(nsub));
444
+ else
445
+ adjoint_t<double>(g64, tape, q_out, v_out, wq, wv, foot, xpos_bar, xrot_bar, vb_bar, wb_bar, q_bar, v_bar, u_bar, aflags, cycles,
446
+ static_cast<int>(nsub));
447
+ }
448
+ #endif
449
+
450
+ void frames(torch::Tensor qpos, torch::Tensor qvel, torch::Tensor bodies, torch::Tensor xpos, torch::Tensor xquat, torch::Tensor xvel,
451
+ torch::Tensor xangvel) {
452
+ const int64_t n = qpos.size(0), nbt = bodies.size(0);
453
+ cudaStream_t s = at::cuda::getCurrentCUDAStream();
454
+ if (qpos.scalar_type() == torch::kFloat32)
455
+ E::k_frames<float><<<static_cast<unsigned>(n), 32, 0, s>>>(g32.V, static_cast<int>(n), qpos.data_ptr<float>(), qvel.data_ptr<float>(),
456
+ static_cast<int>(nbt), bodies.data_ptr<int>(), xpos.data_ptr<float>(),
457
+ xquat.data_ptr<float>(), xvel.data_ptr<float>(), xangvel.data_ptr<float>());
458
+ else
459
+ E::k_frames<double><<<static_cast<unsigned>(n), 32, 0, s>>>(g64.V, static_cast<int>(n), qpos.data_ptr<double>(), qvel.data_ptr<double>(),
460
+ static_cast<int>(nbt), bodies.data_ptr<int>(), xpos.data_ptr<double>(),
461
+ xquat.data_ptr<double>(), xvel.data_ptr<double>(), xangvel.data_ptr<double>());
462
+ CKE(cudaGetLastError());
463
+ }
464
+
465
+ pybind11::dict attrs() {
466
+ pybind11::dict d;
467
+ auto one = [&](const char* name, const void* fn, size_t smem) {
468
+ cudaFuncAttributes a; CKE(cudaFuncGetAttributes(&a, fn));
469
+ int occ = 0; CKE(cudaOccupancyMaxActiveBlocksPerMultiprocessor(&occ, fn, 32, smem));
470
+ d[name] = pybind11::make_tuple(a.numRegs, a.localSizeBytes, a.sharedSizeBytes, occ);
471
+ };
472
+ one("kpre_f32", reinterpret_cast<const void*>(E::kpre_kernel<float>), 0);
473
+ one("kpost_f32", reinterpret_cast<const void*>(E::k_post_f32), 0);
474
+ one("kpost_big_f32", reinterpret_cast<const void*>(E::k_post_big_f32), 0);
475
+ one("frames_f32", reinterpret_cast<const void*>(E::k_frames<float>), 0);
476
+ using FacF = js::soft::adj::RowsBFactory<float, js::soft::adj::GenTab<float>, js::soft::adj::DevCTabV<float>>;
477
+ one("adjoint_f32", reinterpret_cast<const void*>(js::soft::adj::k_adjoint_step<float, FacF>), js::soft::adj::adj_shell_smem<float>());
478
+ return d;
479
+ }
480
+ } // namespace
481
+
482
+ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
483
+ m.def("init", &init, "upload the model (the soft_capi handle built in this library, L2's rbound)");
484
+ m.def("control_step", &control_step, "one control step on device tensors (see soft_engine.py); parts: 1 k_pre, 2 k_post, 4 tail, 8 frames; 16 the row-count order + big kernel, 32 every world on the big kernel (31 = production; a subset of 1-8 only for timing)");
485
+ m.def("frames", &frames, "the tracked bodies' frames and world velocities at given states");
486
+ m.def("adjoint", &adjoint, "one control step's adjoint on the tape the forward wrote (see adjoint_t)");
487
+ m.def("tape_words", []() { return E::TL.words; }, "the tape record's words (one world, one substep)");
488
+ m.def("hand_words", []() { return E::HL.words; }, "the hand record's words per world (the layout the kernels are compiled with)");
489
+ m.def("tail", []() { return std::make_tuple(kTailK, kTailM, g_tail.dyn); }, "v15: (K heavy slots, blocks per SM beside one, padding bytes)");
490
+ m.def("max_chunks", []() { return 15; }, "the most world chunks control_step's parts bits 8-11 take (v8: k_pre .. tail per chunk)");
491
+ #ifdef D16_G1_COMDR
492
+ m.def("comdr", []() { return true; }, "COMDR build: control_step / adjoint take ipo [n, 3] and ipo_body (COMDR_DESIGN.md)");
493
+ #endif
494
+ m.def("attrs", &attrs, "(regs, local bytes, static shared bytes, blocks / SM) of the f32 kernels");
495
+ }
@@ -0,0 +1,40 @@
1
+ #!/bin/bash
2
+ # Build the CPU engine prototype (x14_cpu.cpp) for the host: core/cpu_engine/build.sh [mm|e0|<body tag>] OUT_DIR [extra flags]
3
+ # (a body tag, e.g. 3e0cfe8916ca_mmfloor: core/soft/gpu/generated/body_<tag>.cuh, as engine14's load_ext(body=...) builds it)
4
+ # k_mus_host_tables.inc is k_mus_host.cuh's host part VERBATIM (every line before its first launcher, which uses <<<>>>), closed by the
5
+ # namespace's brace: the muscle tables are built by the header's own code, never by a copy. Prints the library's path.
6
+ set -euo pipefail
7
+ V=${1:-mm}; O=${2:?OUT_DIR}; shift 2 || true
8
+ R=$(cd "$(dirname "$0")/../.." && pwd) # the package directory (this script is <package>/core/cpu_engine/build.sh)
9
+ H=$R/core/soft/gpu/k_mus_host.cuh
10
+ mkdir -p "$O"
11
+ cut=$(grep -n '^// one substep k of the 14x reverse' "$H" | head -1 | cut -d: -f1)
12
+ [ -n "$cut" ] || { echo "build.sh: k_mus_host.cuh's first launcher comment not found"; exit 1; }
13
+ { head -n $((cut - 1)) "$H"; echo "} // namespace js::soft::gpu (closed by build.sh)"; } > "$O/k_mus_host_tables.inc"
14
+ # adj14_tl14.inc: adj14.cuh's tape layout (its namespace line through the #endif that closes TL14's #if), verbatim: the shared kernel block
15
+ # static_asserts the binding's layout against it, and the rest of adj14.cuh (the adjoint and its <<<>>> launcher) is not the CPU engine's
16
+ A=$R/core/soft/gpu/adj14.cuh
17
+ s=$(grep -n '^namespace d16::adj14 {' "$A" | head -1 | cut -d: -f1)
18
+ e=$(awk -v s="$s" 'NR > s && /^#endif/ { print NR; exit }' "$A")
19
+ [ -n "$s" ] && [ -n "$e" ] || { echo "build.sh: adj14.cuh's TL14 block not found"; exit 1; }
20
+ { sed -n "${s},${e}p" "$A"; echo "} // namespace d16::adj14 (closed by build.sh)"; } > "$O/adj14_tl14.inc"
21
+ F=(); [ "$V" = mm ] && F+=(-DD16_X14_MMFLOOR)
22
+ if [ "$V" != mm ] && [ "$V" != e0 ]; then
23
+ BH=$R/core/soft/gpu/generated/body_$V.cuh
24
+ [ -f "$BH" ] || { echo "build.sh: no body header $BH"; exit 1; }
25
+ F+=("-DD16_BODY_HEADER=\"soft/gpu/generated/body_$V.cuh\"")
26
+ grep -q '^#define D16_BODY_NV \(6[5-9]\|[7-9][0-9]\|[1-9][0-9][0-9]\)' "$BH" && F+=(-DD16_NV_GT64)
27
+ fi
28
+ # -ftrivial-auto-var-init=pattern, always (the review, 11-10): every local the kernels leave uninitialized is filled with a pattern, so the
29
+ # CPU engine shows a read of one instead of the fiber stacks' lucky zeros (the first k_act14_vjp's accumulators: NaN on the GPU, a pass here).
30
+ # A compiler without it (GCC < 12: the GPU hosts' g++ 10 / 11) is refused unless D16_CPU_NO_VARINIT=1 says so explicitly (D3 on a GPU host,
31
+ # a forward-only comparison); the opt-out is printed with the build.
32
+ VI=(-ftrivial-auto-var-init=pattern)
33
+ if ! echo 'int main() { return 0; }' | ${CXX:-c++} -x c++ -ftrivial-auto-var-init=pattern -fsyntax-only - 2> /dev/null; then
34
+ [ "${D16_CPU_NO_VARINIT:-0}" = 1 ] || { echo "build.sh: ${CXX:-c++} lacks -ftrivial-auto-var-init=pattern (GCC >= 12 or clang); set CXX, or D16_CPU_NO_VARINIT=1 to build without it"; exit 1; }
35
+ echo "build.sh: WITHOUT -ftrivial-auto-var-init=pattern (${CXX:-c++} lacks it; D16_CPU_NO_VARINIT=1)" >&2
36
+ VI=()
37
+ fi
38
+ ${CXX:-c++} -std=c++17 -O2 -fPIC -shared ${VI[@]+"${VI[@]}"} ${F[@]+"${F[@]}"} "$@" -I "$R/core/cpu_engine/fiber" -I "$O" -I "$R/core" -I "$R/core/include" \
39
+ -I "$R/core/soft/gpu" "$R/core/cpu_engine/x14_cpu.cpp" -o "$O/libx14cpu_$V.so"
40
+ echo "$O/libx14cpu_$V.so"