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,377 @@
1
+ #pragma once
2
+ // Host-side upload of a muscle case's tables for k_mus / muscle_adj / muscle_adj_taped (agent F): the case muscle_ref_gate
3
+ // --export-gpu writes (tools/d16/muscle_ref/kmus_gate.py load_case: the 52 arrays in its fixed order; the tables are a[0..42]
4
+ // and the perm a[51]), plus the per-entry records (fix 5 (i)) built here as the model build makes them. Shared by the test
5
+ // binding, the adjoint test binding and the engine binding, so every caller builds the same tables.
6
+ #include <cuda_runtime.h>
7
+
8
+ #include <cstdio>
9
+ #include <cstdlib>
10
+ #include <vector>
11
+
12
+ #include "k_mus.cuh"
13
+ #include "mus_case_fits.h"
14
+ #if defined(D16_BODY_ROW_CF)
15
+ #include "mus_row_cf.h" // the row's closed form: the entry codes (no CUDA dependency)
16
+ #endif
17
+ #if defined(D16_BODY_MUS_SPLIT)
18
+ #include "mus_classes.h" // the muscle split's host derivation (no CUDA dependency)
19
+ #endif
20
+
21
+ namespace js::soft::gpu {
22
+
23
+ // dims, in kmus_gate.py's order
24
+ enum MusDim { kMusNQ, kMusNV, kMusNM, kMusNSITE, kMusNSLOT, kMusNLEV, kMusNROUND, kMusNNZ, kMusNJE, kMusNSEED, kMusNGENT, kMusNW, kMusKD };
25
+
26
+ // device allocations freed together; up(h, n) copies n elements from the host (h null: uninitialized)
27
+ struct MusPool {
28
+ std::vector<void*> p;
29
+ MusPool() = default;
30
+ MusPool(const MusPool&) = delete;
31
+ MusPool& operator=(const MusPool&) = delete;
32
+ ~MusPool() { for (void* x : p) cudaFree(x); }
33
+ template <class X> X* up(const void* h, size_t n) {
34
+ X* d = nullptr;
35
+ if (cudaMalloc(&d, n * sizeof(X) + 64) != cudaSuccess) return nullptr;
36
+ p.push_back(d);
37
+ if (h && n) cudaMemcpy(d, h, n * sizeof(X), cudaMemcpyHostToDevice);
38
+ return d;
39
+ }
40
+ };
41
+
42
+ // MusBall's host lists (k_mus.cuh): muscle m's joint entries on a ball, in entry order, as (jent_slot[e], vadr[jent_body[e]]).
43
+ // The engine binding and mus_upload_tables both build them here. KMUS_BALL_PLANT 1 (gate builds only) drops each muscle's last
44
+ // ball entry, which the bitwise gate must catch.
45
+ #ifndef KMUS_BALL_PLANT
46
+ #define KMUS_BALL_PLANT 0
47
+ #endif
48
+ inline void mus_ball_list(int nm, const int* jent_off, const int* jent_body, const int* jent_slot, const int* body_jtype,
49
+ const int* vadr, std::vector<int>& off, std::vector<int>& sv) {
50
+ off.assign(static_cast<size_t>(nm) + 1, 0);
51
+ sv.clear();
52
+ for (int m = 0; m < nm; ++m) {
53
+ int last = -1;
54
+ for (int e = jent_off[m]; e < jent_off[m + 1]; ++e)
55
+ if (body_jtype[jent_body[e]] == js::soft::kMJBall) last = e;
56
+ int prev = -1, hits = 0;
57
+ for (int e = jent_off[m]; e < jent_off[m + 1]; ++e) {
58
+ if (body_jtype[jent_body[e]] != js::soft::kMJBall) continue;
59
+ if (KMUS_BALL_PLANT == 1 && e == last) continue;
60
+ if (e <= prev) { std::fprintf(stderr, "mus_ball_list: muscle %d entry %d out of order\n", m, e); std::abort(); }
61
+ prev = e;
62
+ sv.push_back(jent_slot[e]);
63
+ sv.push_back(vadr[jent_body[e]]);
64
+ }
65
+ off[static_cast<size_t>(m) + 1] = static_cast<int>(sv.size() / 2);
66
+ // the review: the list's length equals the old loop's ball hits, counted independently (a duplicated or moved entry would
67
+ // leave the outputs bitwise, since its writes repeat or land on distinct slots, so it must fail here instead)
68
+ for (int e = jent_off[m]; e < jent_off[m + 1]; ++e) hits += body_jtype[jent_body[e]] == js::soft::kMJBall ? 1 : 0;
69
+ const int len = off[static_cast<size_t>(m) + 1] - off[static_cast<size_t>(m)];
70
+ if (len != hits - (KMUS_BALL_PLANT == 1 && hits > 0 ? 1 : 0)) {
71
+ std::fprintf(stderr, "mus_ball_list: muscle %d lists %d ball entries, the tables have %d\n", m, len, hits);
72
+ std::abort();
73
+ }
74
+ }
75
+ }
76
+
77
+ #ifdef D16_X14_MILLARD
78
+ // The Millard 2013 case's eleven arrays (muscle_ref_gate --export-gpu appends them for a Millard model; kmus_gate.py MILLARD, in this
79
+ // order): law [3] (kLawMillard, K sets, NC curves: 4 per set, then the muscles' own passive curves), mset [nm], pen_h, lce_min,
80
+ // pfl_a, pfl_b [nm], mc_i [NC][2], mc_f [NC][8], mc_knot [nk][3], mc_sinmax [K], pfl_curve [nm]. Checked on the host (the kernels
81
+ // carry no device asserts): the law, every muscle's set and passive curve in range, every curve at least 2 knots inside the knot
82
+ // array. Returns K, NC and the knot count nk.
83
+ inline void mus_millard_check(int nm, const int* law, const int* mset, const int* mc_i, const int* pfl_curve, int& K, int& NC, int& nk) {
84
+ if (law[0] != kLawMillard || law[1] < 1 || law[2] < 4 * law[1]) {
85
+ std::fprintf(stderr, "mus_millard_check: law %d, %d sets, %d curves\n", law[0], law[1], law[2]); std::abort();
86
+ }
87
+ K = law[1]; NC = law[2];
88
+ nk = 0;
89
+ for (int i = 0; i < NC; ++i) {
90
+ if (mc_i[2 * i] < 0 || mc_i[2 * i + 1] < 2) { std::fprintf(stderr, "mus_millard_check: curve %d\n", i); std::abort(); }
91
+ if (mc_i[2 * i] + mc_i[2 * i + 1] > nk) nk = mc_i[2 * i] + mc_i[2 * i + 1];
92
+ }
93
+ for (int m = 0; m < nm; ++m) {
94
+ if (mset[m] < 0 || mset[m] >= K) { std::fprintf(stderr, "mus_millard_check: muscle %d set %d of %d\n", m, mset[m], K); std::abort(); }
95
+ const bool own = pfl_curve[m] >= 4 * K && pfl_curve[m] < NC, set = pfl_curve[m] == 4 * mset[m] + kMCurvePFL;
96
+ if (!own && !set) { std::fprintf(stderr, "mus_millard_check: muscle %d passive curve %d\n", m, pfl_curve[m]); std::abort(); }
97
+ }
98
+ }
99
+ #endif
100
+
101
+ // a: the case's host arrays (T for the float tables, int32 for the integer ones), dm: its dims. NQ / NV are the model's.
102
+ // A Millard build (-DD16_X14_MILLARD) also reads the law's eleven arrays at a[52 ..] (mus_millard_check).
103
+ template <class T, int NQ, int NV>
104
+ void mus_upload_tables(MusPool& P, const int* dm, void* const* a, MuscleTables<T>& t, MusSlots<T>& sl, MusBall& bl) {
105
+ const int nm = dm[kMusNM], nsite = dm[kMusNSITE], ns = dm[kMusNSLOT];
106
+ t.nm = nm; t.nsite = nsite; t.nv = NV; t.nq = NQ; t.nbody = ns;
107
+ const T** vals[15] = {&t.fmax, &t.lopt, &t.lslack, &t.vmax, &t.W, &t.C, &t.N, &t.K, &t.eref, &t.pe_rest, &t.pe_eps, &t.beta,
108
+ &t.tau_act, &t.tau_deact, &t.tausmooth};
109
+ for (int i = 0; i < 15; ++i) *vals[i] = P.up<T>(a[i], nm);
110
+ t.rigid = P.up<int>(a[15], nm); t.site_off = P.up<int>(a[16], nm + 1); t.row_off = P.up<int>(a[17], nm + 1);
111
+ t.row_dof = P.up<int>(a[18], dm[kMusNNZ]); t.jent_off = P.up<int>(a[19], nm + 1); t.jent_body = P.up<int>(a[20], dm[kMusNJE]);
112
+ t.jent_mask = P.up<int>(a[21], dm[kMusNJE]); t.jent_slot = P.up<int>(a[22], dm[kMusNJE]);
113
+ t.site_body = P.up<int>(a[23], nsite); t.site_off3 = P.up<T>(a[24], 3 * nsite); t.site_moving = P.up<int>(a[25], nsite);
114
+ t.site_cdof_q = P.up<int>(a[26], nsite); t.site_slot = P.up<int>(a[27], nsite); t.site_coef = P.up<T>(a[28], 15 * nsite);
115
+ t.body_jtype = P.up<int>(a[29], ns); t.body_jaxis = P.up<T>(a[30], 3 * ns); t.body_cpl_qadr = P.up<int>(a[31], ns);
116
+ t.body_cpl_coef = P.up<T>(a[32], 5 * ns);
117
+ sl.nslot = ns; sl.nlev = dm[kMusNLEV]; sl.nround = dm[kMusNROUND]; sl.nseed = dm[kMusNSEED];
118
+ sl.lev_off = P.up<int>(a[33], dm[kMusNLEV] + 1); sl.parent = P.up<int>(a[34], ns); sl.kjt = P.up<int>(a[35], ns);
119
+ sl.qadr = P.up<int>(a[36], ns); sl.vadr = P.up<int>(a[37], ns); sl.pos = P.up<T>(a[38], 3 * ns); sl.quat = P.up<T>(a[39], 4 * ns);
120
+ sl.cpl_qadr = t.body_cpl_qadr; sl.cpl_coef = t.body_cpl_coef; sl.axis = t.body_jaxis;
121
+ sl.g_off = P.up<int>(a[40], dm[kMusNROUND] * NV + 1); sl.g_ent = P.up<int>(a[41], dm[kMusNGENT]);
122
+ sl.seed = P.up<int>(a[42], 3 * dm[kMusNSEED]);
123
+ sl.perm = P.up<int>(a[51], nm); // the rounds' muscle order (identity unless the case is cost-sorted)
124
+ // the per-entry records: (body, mask, slot, jtype | (cpl_qadr + 1) << 8; c1..c4 of the coupling polynomial, the joint axis)
125
+ const int nje = dm[kMusNJE];
126
+ const int* jb = static_cast<const int*>(a[20]); const int* jm = static_cast<const int*>(a[21]); const int* js = static_cast<const int*>(a[22]);
127
+ const int* bj = static_cast<const int*>(a[29]); const T* bax = static_cast<const T*>(a[30]);
128
+ const int* bcq = static_cast<const int*>(a[31]); const T* bcc = static_cast<const T*>(a[32]);
129
+ #if defined(D16_BODY_ROW_CF) // the records carry the entries' codes (mus_row_cf.h), not their masks
130
+ std::vector<int> rcode;
131
+ mus_row_codes(nm, static_cast<const int*>(a[16]), static_cast<const int*>(a[19]), jm, rcode);
132
+ jm = rcode.data();
133
+ #endif
134
+ std::vector<int> ri(4 * static_cast<size_t>(nje)); std::vector<T> rf(8 * static_cast<size_t>(nje), T(0));
135
+ for (int e = 0; e < nje; ++e) {
136
+ const int b = jb[e];
137
+ ri[4 * e] = b; ri[4 * e + 1] = jm[e]; ri[4 * e + 2] = js[e]; ri[4 * e + 3] = bj[b] | ((bcq[b] + 1) << 8);
138
+ for (int k = 0; k < 4; ++k) rf[8 * e + k] = bcc[5 * b + 1 + k];
139
+ for (int k = 0; k < 3; ++k) rf[8 * e + 4 + k] = bax[3 * b + k];
140
+ }
141
+ sl.erec_i = reinterpret_cast<const int4*>(P.up<int>(ri.data(), ri.size())); sl.erec_f = P.up<T>(rf.data(), rf.size());
142
+ std::vector<int> boff, bsv; // the ball term's lists (MusBall)
143
+ mus_ball_list(nm, static_cast<const int*>(a[19]), jb, js, bj, static_cast<const int*>(a[37]), boff, bsv);
144
+ bl.off = P.up<int>(boff.data(), boff.size()); bl.sv = P.up<int>(bsv.data(), bsv.size());
145
+ #ifdef D16_X14_MILLARD
146
+ {
147
+ int K = 0, NC = 0, nk = 0;
148
+ mus_millard_check(nm, static_cast<const int*>(a[52]), static_cast<const int*>(a[53]), static_cast<const int*>(a[58]),
149
+ static_cast<const int*>(a[62]), K, NC, nk);
150
+ t.law = kLawMillard; t.nmset = K; t.ncurve = NC; t.pfl_curve = P.up<int>(a[62], nm);
151
+ t.mset = P.up<int>(a[53], nm); t.pen_h = P.up<T>(a[54], nm); t.lce_min = P.up<T>(a[55], nm); t.pfl_a = P.up<T>(a[56], nm);
152
+ t.pfl_b = P.up<T>(a[57], nm); t.mc_i = P.up<int>(a[58], 2 * static_cast<size_t>(NC)); t.mc_f = P.up<T>(a[59], 8 * static_cast<size_t>(NC));
153
+ t.mc_knot = P.up<T>(a[60], 3 * static_cast<size_t>(nk)); t.mc_sinmax = P.up<T>(a[61], K);
154
+ }
155
+ #endif
156
+ }
157
+
158
+ // one substep k of the 14x reverse (the step 4): muscle_adj_taped on n worlds, the stream s. The caller zeroes u_bar before
159
+ // k = 4 and chains (lce_k_bar, a_k_bar) into substep k - 1's (lce_{k+1}_bar, a_{k+1}_bar).
160
+ template <class T, int NS, int KD, int NSLOT, int NQ, int NV, int KMUS_P(NM)>
161
+ void launch_muscle_adj_taped(const MuscleTables<T>& t, const MusSlots<T>& sl, const MusBall& bl, const AdjTape<T>& tp, T dt, int n,
162
+ const T* tau_bar, const T* lce_next_bar, const T* a_next_bar, T* qmus, T* lce_bar, T* a_bar,
163
+ cudaStream_t s = 0) {
164
+ muscle_adj_taped<T, NS, KD, NSLOT, NQ, NV, KMUS_A(NM)><<<n, 32, 0, s>>>(t, sl, tp, dt, tau_bar, lce_next_bar, a_next_bar, qmus, lce_bar, a_bar,
165
+ bl);
166
+ }
167
+
168
+
169
+ #if defined(D16_BODY_MUS_SPLIT)
170
+ // ---- The muscle stage by class (2026-11-08; tools/d16_bodies/MUSCLE_SPLIT.md, the review R1-R5) ----
171
+ // A body header that defines D16_BODY_MUS_SPLIT (gen_body.py --mus-split) names two classes, 0 narrow and 1 wide, with each one's muscle count,
172
+ // widths and slot count. Each class runs its own instantiation of the muscle stage on its own tables, derived on the host from the same case
173
+ // arrays as the full tables (mus_classes.h), which stay uploaded: k_mus_equil runs on them (the Q3). R1: the class kernels loop over their
174
+ // class's muscles while every stride, tape word and per-muscle index stays global (NM).
175
+ static_assert(D16_BODY_NV > 64, "the muscle split is a phase B body's (gen_body.py --mus-split)");
176
+ static_assert(D16_BODY_MC0_NM + D16_BODY_MC1_NM == D16_BODY_NM && D16_BODY_MC0_NM > 0 && D16_BODY_MC1_NM > 0, "the two classes cover the body's muscles");
177
+ static_assert(D16_BODY_MC0_NS <= D16_BODY_NS && D16_BODY_MC0_KD <= D16_BODY_MKD && D16_BODY_MC1_NS <= D16_BODY_NS && D16_BODY_MC1_KD <= D16_BODY_MKD &&
178
+ D16_BODY_MC0_NSLOT <= D16_BODY_NSLOT && D16_BODY_MC1_NSLOT <= D16_BODY_NSLOT,
179
+ "each class's widths are within the body's");
180
+ // KMUS_SPLIT_PLANT 1 (gate builds only; the review): the wide class starts from acc = 0 instead of continuing the narrow sum (R3 broken), which
181
+ // split_gate.py's bitwise comparison must catch in tau and q_bar
182
+ #ifndef KMUS_SPLIT_PLANT
183
+ #define KMUS_SPLIT_PLANT 0
184
+ #endif
185
+ constexpr bool kMusWideAccIn = KMUS_SPLIT_PLANT != 1;
186
+ #if defined(D16_BODY_MC_FILL)
187
+ constexpr bool kMusFill = true; // the 12-round partition (mus_classes.h mus_class_vec): the binding's perm'' control takes the same rule
188
+ #else
189
+ constexpr bool kMusFill = false;
190
+ #endif
191
+ template <class T> struct MusClasses {
192
+ MuscleTables<T> t[2];
193
+ MusSlots<T> sl[2];
194
+ };
195
+
196
+ // Derive (with R4's checks, mus_classes_host), check against the header and upload both classes' tables. dm / a: the case as
197
+ // mus_upload_tables takes it; t / sl: the full tables uploaded from the same arrays (the classes copy their value arrays, MusBall, seed and
198
+ // erec_f); mc: out.
199
+ template <class T, int NV>
200
+ void mus_class_upload(MusPool& P, const int* dm, void* const* a, const MuscleTables<T>& t, const MusSlots<T>& sl, MusClasses<T>& mc) {
201
+ constexpr int CNS[2] = {D16_BODY_MC0_NS, D16_BODY_MC1_NS}, CKD[2] = {D16_BODY_MC0_KD, D16_BODY_MC1_KD};
202
+ constexpr int CNM[2] = {D16_BODY_MC0_NM, D16_BODY_MC1_NM}, CNSLOT[2] = {D16_BODY_MC0_NSLOT, D16_BODY_MC1_NSLOT};
203
+ if (dm[kMusNV] != NV || dm[kMusNM] != D16_BODY_NM || dm[kMusNSLOT] != D16_BODY_NSLOT) mus_class_fail("the case is not this body's", -1, dm[kMusNM]);
204
+ MusClassHost<T> h[2];
205
+ #if defined(D16_BODY_MC_FILL)
206
+ mus_classes_host<T>(dm, a, CNS, CKD, true, h); // the 12-round partition (gen_body --mus-fill)
207
+ #else
208
+ mus_classes_host<T>(dm, a, CNS, CKD, false, h);
209
+ #endif
210
+ for (int c = 0; c < 2; ++c) {
211
+ if (h[c].nm != CNM[c]) mus_class_fail("the class's muscle count is not the header's", c, h[c].nm);
212
+ if (h[c].nslot != CNSLOT[c]) mus_class_fail("the class's slot count is not the header's", c, h[c].nslot);
213
+ const MusClassHost<T>& o = h[c];
214
+ MuscleTables<T>& ct = mc.t[c];
215
+ ct = t;
216
+ ct.nbody = o.nslot;
217
+ ct.site_body = P.up<int>(o.site_body.data(), o.site_body.size()); ct.jent_body = P.up<int>(o.jent_body.data(), o.jent_body.size());
218
+ ct.body_jtype = P.up<int>(o.jtype.data(), o.jtype.size()); ct.body_jaxis = P.up<T>(o.axis.data(), o.axis.size());
219
+ ct.body_cpl_qadr = P.up<int>(o.cpl_qadr.data(), o.cpl_qadr.size()); ct.body_cpl_coef = P.up<T>(o.cpl_coef.data(), o.cpl_coef.size());
220
+ MusSlots<T>& cs = mc.sl[c];
221
+ cs = sl; // nseed, seed (q indices) and erec_f (per-entry values) stay the full tables'
222
+ cs.nslot = o.nslot; cs.nlev = o.nlev; cs.nround = o.nround;
223
+ cs.lev_off = P.up<int>(o.lev_off.data(), o.lev_off.size()); cs.parent = P.up<int>(o.parent.data(), o.parent.size());
224
+ cs.kjt = P.up<int>(o.kjt.data(), o.kjt.size()); cs.qadr = P.up<int>(o.qadr.data(), o.qadr.size()); cs.vadr = P.up<int>(o.vadr.data(), o.vadr.size());
225
+ cs.pos = P.up<T>(o.pos.data(), o.pos.size()); cs.quat = P.up<T>(o.quat.data(), o.quat.size());
226
+ cs.cpl_qadr = ct.body_cpl_qadr; cs.cpl_coef = ct.body_cpl_coef; cs.axis = ct.body_jaxis;
227
+ cs.g_off = P.up<int>(o.g_off.data(), o.g_off.size()); cs.g_ent = P.up<int>(o.g_ent.data(), o.g_ent.size());
228
+ cs.perm = P.up<int>(o.perm.data(), o.perm.size());
229
+ cs.erec_i = reinterpret_cast<const int4*>(P.up<int>(o.erec_i.data(), o.erec_i.size()));
230
+ for (const void* p : {static_cast<const void*>(ct.site_body), static_cast<const void*>(ct.body_cpl_coef), static_cast<const void*>(cs.g_ent),
231
+ static_cast<const void*>(cs.perm), static_cast<const void*>(cs.erec_i)})
232
+ if (p == nullptr) mus_class_fail("a device allocation failed", c, -1);
233
+ }
234
+ }
235
+
236
+ #if defined(D16_BODY_MUS_W2)
237
+ constexpr bool kMusW2 = true; // the narrow class at two warps per world (PREREG_MW2.md; k_mus.cuh's _w2 kernels, 64 threads)
238
+ #else
239
+ constexpr bool kMusW2 = false;
240
+ #endif
241
+ // One class's forward launch: c 0 the narrow class (at two warps when w2), 1 the wide class (continuing tau, R3). Tp: NoMusTape (k_mus) or a
242
+ // tape policy (k_mus_taped).
243
+ template <class T, int NQ, int NV, int NM, class Tp>
244
+ void mus_fwd_one(int c, bool w2, const MusClasses<T>& C, unsigned n, cudaStream_t s, const T* q, const T* lce, const T* a, const T* u, T dt, int niter,
245
+ T* tau, T* lce_o, T* a_o, T* F_o, Tp tp) {
246
+ constexpr bool kTaped = !std::is_same_v<Tp, NoMusTape>;
247
+ if (c == 0) {
248
+ #if defined(D16_BODY_MUS_W2)
249
+ if (w2) {
250
+ if constexpr (kTaped)
251
+ k_mus_taped_w2<T, D16_BODY_MC0_NS, D16_BODY_MC0_KD, D16_BODY_MC0_NSLOT, NQ, NV, NM, Tp, D16_BODY_MC0_NM><<<n, 64, 0, s>>>(
252
+ C.t[0], C.sl[0], q, lce, a, u, dt, niter, tau, lce_o, a_o, F_o, tp);
253
+ else
254
+ k_mus_w2<T, D16_BODY_MC0_NS, D16_BODY_MC0_KD, D16_BODY_MC0_NSLOT, NQ, NV, NM, D16_BODY_MC0_NM><<<n, 64, 0, s>>>(
255
+ C.t[0], C.sl[0], q, lce, a, u, dt, niter, tau, lce_o, a_o, F_o);
256
+ return;
257
+ }
258
+ #endif
259
+ if (w2) { std::fprintf(stderr, "mus_fwd_one: two warps requested in a build without D16_BODY_MUS_W2\n"); std::abort(); }
260
+ if constexpr (kTaped)
261
+ k_mus_taped<T, D16_BODY_MC0_NS, D16_BODY_MC0_KD, D16_BODY_MC0_NSLOT, NQ, NV, NM, Tp, D16_BODY_MC0_NM, false><<<n, 32, 0, s>>>(
262
+ C.t[0], C.sl[0], q, lce, a, u, dt, niter, tau, lce_o, a_o, F_o, tp);
263
+ else
264
+ k_mus<T, D16_BODY_MC0_NS, D16_BODY_MC0_KD, D16_BODY_MC0_NSLOT, NQ, NV, NM, D16_BODY_MC0_NM, false><<<n, 32, 0, s>>>(
265
+ C.t[0], C.sl[0], q, lce, a, u, dt, niter, tau, lce_o, a_o, F_o);
266
+ return;
267
+ }
268
+ if constexpr (kTaped)
269
+ k_mus_taped<T, D16_BODY_MC1_NS, D16_BODY_MC1_KD, D16_BODY_MC1_NSLOT, NQ, NV, NM, Tp, D16_BODY_MC1_NM, kMusWideAccIn><<<n, 32, 0, s>>>(
270
+ C.t[1], C.sl[1], q, lce, a, u, dt, niter, tau, lce_o, a_o, F_o, tp);
271
+ else
272
+ k_mus<T, D16_BODY_MC1_NS, D16_BODY_MC1_KD, D16_BODY_MC1_NSLOT, NQ, NV, NM, D16_BODY_MC1_NM, kMusWideAccIn><<<n, 32, 0, s>>>(
273
+ C.t[1], C.sl[1], q, lce, a, u, dt, niter, tau, lce_o, a_o, F_o);
274
+ }
275
+ // The forward's two launches, narrow from acc = 0 (at two warps in a D16_BODY_MUS_W2 build) and then wide continuing tau (R3), on stream s.
276
+ // R5: step_t and the gate binding call this, so no caller can launch one class alone.
277
+ template <class T, int NQ, int NV, int NM, class Tp>
278
+ void mus_fwd_cls(const MusClasses<T>& c, unsigned n, cudaStream_t s, const T* q, const T* lce, const T* a, const T* u, T dt, int niter, T* tau,
279
+ T* lce_o, T* a_o, T* F_o, Tp tp) {
280
+ mus_fwd_one<T, NQ, NV, NM>(0, kMusW2, c, n, s, q, lce, a, u, dt, niter, tau, lce_o, a_o, F_o, tp);
281
+ mus_fwd_one<T, NQ, NV, NM>(1, false, c, n, s, q, lce, a, u, dt, niter, tau, lce_o, a_o, F_o, tp);
282
+ }
283
+ // The test builds' selection (bindings/muscle_gpu_test.cu's variants 2-6 as sel = variant - 2): 0 both classes (mus_fwd_cls), 1 the narrow class
284
+ // alone, 2 the wide class alone (its sum from a zeroed tau), 3 both with the narrow class at one warp, 4 the narrow class alone at one warp. One
285
+ // class alone does not compute the stage; it times or profiles it. Sel 3 is the two-warp build's per-muscle bitwise and summation-order control.
286
+ template <class T, int NQ, int NV, int NM, class Tp>
287
+ void mus_fwd_cls_sel(int sel, const MusClasses<T>& c, unsigned n, cudaStream_t s, const T* q, const T* lce, const T* a, const T* u, T dt, int niter,
288
+ T* tau, T* lce_o, T* a_o, T* F_o, Tp tp) {
289
+ if (sel == 2) {
290
+ cudaMemsetAsync(tau, 0, sizeof(T) * static_cast<size_t>(n) * NV, s);
291
+ mus_fwd_one<T, NQ, NV, NM>(1, false, c, n, s, q, lce, a, u, dt, niter, tau, lce_o, a_o, F_o, tp);
292
+ return;
293
+ }
294
+ mus_fwd_one<T, NQ, NV, NM>(0, kMusW2 && sel < 3, c, n, s, q, lce, a, u, dt, niter, tau, lce_o, a_o, F_o, tp);
295
+ if (sel == 0 || sel == 3) mus_fwd_one<T, NQ, NV, NM>(1, false, c, n, s, q, lce, a, u, dt, niter, tau, lce_o, a_o, F_o, tp);
296
+ }
297
+ // One class's adjoint launch (muscle_adj_taped, one substep): c 0 narrow (two warps when w2) writing qmus, 1 wide continuing it (R3). MusBall is
298
+ // global (indexed by the global muscle, holding row slots and dofs), so both classes take the full tables' (the Q1).
299
+ template <class T, int NQ, int NV, int NM>
300
+ void muscle_adj_taped_one(int c, bool w2, const MusClasses<T>& C, const MusBall& bl, const AdjTape<T>& tp, T dt, int n, const T* tau_bar,
301
+ const T* lce_next_bar, const T* a_next_bar, T* qmus, T* lce_bar, T* a_bar, cudaStream_t s) {
302
+ if (c == 0) {
303
+ #if defined(D16_BODY_MUS_W2)
304
+ if (w2) {
305
+ muscle_adj_taped_w2<T, D16_BODY_MC0_NS, D16_BODY_MC0_KD, D16_BODY_MC0_NSLOT, NQ, NV, NM, D16_BODY_MC0_NM><<<n, 64, 0, s>>>(
306
+ C.t[0], C.sl[0], tp, dt, tau_bar, lce_next_bar, a_next_bar, qmus, lce_bar, a_bar, bl);
307
+ return;
308
+ }
309
+ #endif
310
+ if (w2) { std::fprintf(stderr, "muscle_adj_taped_one: two warps requested in a build without D16_BODY_MUS_W2\n"); std::abort(); }
311
+ launch_muscle_adj_taped<T, D16_BODY_MC0_NS, D16_BODY_MC0_KD, D16_BODY_MC0_NSLOT, NQ, NV, NM, D16_BODY_MC0_NM, false>(
312
+ C.t[0], C.sl[0], bl, tp, dt, n, tau_bar, lce_next_bar, a_next_bar, qmus, lce_bar, a_bar, s);
313
+ return;
314
+ }
315
+ launch_muscle_adj_taped<T, D16_BODY_MC1_NS, D16_BODY_MC1_KD, D16_BODY_MC1_NSLOT, NQ, NV, NM, D16_BODY_MC1_NM, kMusWideAccIn>(
316
+ C.t[1], C.sl[1], bl, tp, dt, n, tau_bar, lce_next_bar, a_next_bar, qmus, lce_bar, a_bar, s);
317
+ }
318
+ // The adjoint's two launches (adj14_control_step_mus's), narrow writing qmus and then wide continuing it (R3)
319
+ template <class T, int NQ, int NV, int NM>
320
+ void launch_muscle_adj_taped_cls(const MusClasses<T>& c, const MusBall& bl, const AdjTape<T>& tp, T dt, int n, const T* tau_bar,
321
+ const T* lce_next_bar, const T* a_next_bar, T* qmus, T* lce_bar, T* a_bar, cudaStream_t s = 0) {
322
+ muscle_adj_taped_one<T, NQ, NV, NM>(0, kMusW2, c, bl, tp, dt, n, tau_bar, lce_next_bar, a_next_bar, qmus, lce_bar, a_bar, s);
323
+ muscle_adj_taped_one<T, NQ, NV, NM>(1, false, c, bl, tp, dt, n, tau_bar, lce_next_bar, a_next_bar, qmus, lce_bar, a_bar, s);
324
+ }
325
+ // the taped adjoint's selection (as mus_fwd_cls_sel's sel)
326
+ template <class T, int NQ, int NV, int NM>
327
+ void launch_muscle_adj_taped_cls_sel(int sel, const MusClasses<T>& c, const MusBall& bl, const AdjTape<T>& tp, T dt, int n, const T* tau_bar,
328
+ const T* lce_next_bar, const T* a_next_bar, T* qmus, T* lce_bar, T* a_bar, cudaStream_t s = 0) {
329
+ if (sel == 2) {
330
+ cudaMemsetAsync(qmus, 0, sizeof(T) * static_cast<size_t>(n) * NV, s);
331
+ muscle_adj_taped_one<T, NQ, NV, NM>(1, false, c, bl, tp, dt, n, tau_bar, lce_next_bar, a_next_bar, qmus, lce_bar, a_bar, s);
332
+ return;
333
+ }
334
+ muscle_adj_taped_one<T, NQ, NV, NM>(0, kMusW2 && sel < 3, c, bl, tp, dt, n, tau_bar, lce_next_bar, a_next_bar, qmus, lce_bar, a_bar, s);
335
+ if (sel == 0 || sel == 3) muscle_adj_taped_one<T, NQ, NV, NM>(1, false, c, bl, tp, dt, n, tau_bar, lce_next_bar, a_next_bar, qmus, lce_bar, a_bar, s);
336
+ }
337
+ // One class's contiguous adjoint launch (muscle_adj: the gate binding's reference path)
338
+ template <class T, int NQ, int NV, int NM>
339
+ void muscle_adj_one(int c, bool w2, const MusClasses<T>& C, int n, const T* q, const T* lce, const T* a, const T* u, const T* lnew, T dt, const T* tb,
340
+ const T* lb, const T* ab, T* qb, T* lpb, T* apb, T* ub, const MusBall& bl, cudaStream_t s) {
341
+ if (c == 0) {
342
+ #if defined(D16_BODY_MUS_W2)
343
+ if (w2) {
344
+ muscle_adj_w2<T, D16_BODY_MC0_NS, D16_BODY_MC0_KD, D16_BODY_MC0_NSLOT, NQ, NV, NM, D16_BODY_MC0_NM><<<n, 64, 0, s>>>(
345
+ C.t[0], C.sl[0], q, lce, a, u, lnew, dt, tb, lb, ab, qb, lpb, apb, ub, bl);
346
+ return;
347
+ }
348
+ #endif
349
+ if (w2) { std::fprintf(stderr, "muscle_adj_one: two warps requested in a build without D16_BODY_MUS_W2\n"); std::abort(); }
350
+ muscle_adj<T, D16_BODY_MC0_NS, D16_BODY_MC0_KD, D16_BODY_MC0_NSLOT, NQ, NV, NM, D16_BODY_MC0_NM, false><<<n, 32, 0, s>>>(
351
+ C.t[0], C.sl[0], q, lce, a, u, lnew, dt, tb, lb, ab, qb, lpb, apb, ub, bl);
352
+ return;
353
+ }
354
+ muscle_adj<T, D16_BODY_MC1_NS, D16_BODY_MC1_KD, D16_BODY_MC1_NSLOT, NQ, NV, NM, D16_BODY_MC1_NM, kMusWideAccIn><<<n, 32, 0, s>>>(
355
+ C.t[1], C.sl[1], q, lce, a, u, lnew, dt, tb, lb, ab, qb, lpb, apb, ub, bl);
356
+ }
357
+ template <class T, int NQ, int NV, int NM>
358
+ void launch_muscle_adj_cls(const MusClasses<T>& c, int n, const T* q, const T* lce, const T* a, const T* u, const T* lnew, T dt, const T* tb,
359
+ const T* lb, const T* ab, T* qb, T* lpb, T* apb, T* ub, const MusBall& bl, cudaStream_t s = 0) {
360
+ muscle_adj_one<T, NQ, NV, NM>(0, kMusW2, c, n, q, lce, a, u, lnew, dt, tb, lb, ab, qb, lpb, apb, ub, bl, s);
361
+ muscle_adj_one<T, NQ, NV, NM>(1, false, c, n, q, lce, a, u, lnew, dt, tb, lb, ab, qb, lpb, apb, ub, bl, s);
362
+ }
363
+ // the contiguous adjoint's selection (as mus_fwd_cls_sel's sel; the wide class alone continues a zeroed q_bar)
364
+ template <class T, int NQ, int NV, int NM>
365
+ void launch_muscle_adj_cls_sel(int sel, const MusClasses<T>& c, int n, const T* q, const T* lce, const T* a, const T* u, const T* lnew, T dt,
366
+ const T* tb, const T* lb, const T* ab, T* qb, T* lpb, T* apb, T* ub, const MusBall& bl, cudaStream_t s = 0) {
367
+ if (sel == 2) {
368
+ cudaMemsetAsync(qb, 0, sizeof(T) * static_cast<size_t>(n) * NV, s);
369
+ muscle_adj_one<T, NQ, NV, NM>(1, false, c, n, q, lce, a, u, lnew, dt, tb, lb, ab, qb, lpb, apb, ub, bl, s);
370
+ return;
371
+ }
372
+ muscle_adj_one<T, NQ, NV, NM>(0, kMusW2 && sel < 3, c, n, q, lce, a, u, lnew, dt, tb, lb, ab, qb, lpb, apb, ub, bl, s);
373
+ if (sel == 0 || sel == 3) muscle_adj_one<T, NQ, NV, NM>(1, false, c, n, q, lce, a, u, lnew, dt, tb, lb, ab, qb, lpb, apb, ub, bl, s);
374
+ }
375
+ #endif
376
+
377
+ } // namespace js::soft::gpu
@@ -0,0 +1,52 @@
1
+ #pragma once
2
+ // D16 k_pre (2026-11-02): the first kernel of a substep in NablaEngine's split (k_pre -> hand -> k_post).
3
+ // One world per 32-thread block:
4
+ // 1. p_world (core/soft/gpu/kernel_p.cuh): the smooth dynamics. It writes the hand's smooth block (M unfactored,
5
+ // qfrc_smooth, qacc_smooth, the clamp mask) and leaves the poses, dof axes and qvel in shared memory (SharedP's live
6
+ // block);
7
+ // 2. L2 v2 (core/soft/gpu/l2v2.cuh): collision and rows from that live block into the hand's counts, contact and row
8
+ // blocks, and the world's nefc into a dense array (k_post's row-count dispatch);
9
+ // 3. (when given) the tape's POSE block: the bodies' frames at the substep's input q, from the live block (tape.h).
10
+ // Shared memory: L2's geometry (L2Geo) and its contact table (L2Keep) lie over p_world's scratch, which is dead when p_world
11
+ // returns; the live block stays below them.
12
+ // The model header (tools/d16/l1_gen.py) and D16_MODEL_NS must come before this file, as for kernel_p.cuh.
13
+ #include <cstddef>
14
+
15
+ #include "kernel_p.cuh"
16
+ #include "l2v2.cuh"
17
+
18
+ namespace js::soft::gpu {
19
+
20
+ template <class T, int NG, int NP, int NC> struct KPreShared {
21
+ // the live block's end, rounded to 16 bytes: everything above it in SharedP is p_world's scratch
22
+ static constexpr size_t kLive = (offsetof(d16::kp::SharedP<T>, qpos) + 15) / 16 * 16;
23
+ struct Over {
24
+ unsigned char live[kLive];
25
+ L2Geo<T, NG, NP, NC> g;
26
+ L2Keep<NC> k;
27
+ };
28
+ union {
29
+ d16::kp::SharedP<T> p;
30
+ Over o;
31
+ };
32
+ };
33
+
34
+ // One world's k_pre. V: the model's values (p_world's table); m2: L2's model tables; h: the hand's layout (h.nc == NC,
35
+ // h.nr == NR); rec: this world's hand record; pose: this world's tape POSE block (xpos [NB][3] then xquat [NB][4]) or null.
36
+ // E: the external-force policy (kernel_p.cuh's NoTauExt, the default and the G1's, or TauExt<T> with this world's tau_ext).
37
+ template <class T, int NG, int NP, int NC, int NR, class E = d16::kp::NoTauExt>
38
+ __device__ void k_pre_world(KPreShared<T, NG, NP, NC>& sh, const T* __restrict__ V, const L2Tab<T>& m2, const HandLayout& h,
39
+ const T* __restrict__ qpos, const T* __restrict__ qvel, const T* __restrict__ ctrl, T fric, T* rec,
40
+ int* nefc_out, T* pose, int lane, long long* tmr_p, long long* tmr_l2, const E& ext = E{}) {
41
+ using namespace d16::kp;
42
+ p_world<T, E>(sh.p, V, qpos, qvel, ctrl, lane, rec, tmr_p, ext);
43
+ __syncwarp();
44
+ if (pose) { // the frames L2 is about to use, for the tape (coalesced: the live block's poses are contiguous)
45
+ for (int k = lane; k < 3 * NB; k += 32) pose[k] = (&sh.p.xpos[0][0])[k];
46
+ for (int k = lane; k < 4 * NB; k += 32) pose[3 * NB + k] = (&sh.p.xquat[0][0])[k];
47
+ }
48
+ const L2In<T> in{&sh.p.xpos[0][0], &sh.p.xquat[0][0], &sh.p.dofax[0][0], qpos, sh.p.qvel};
49
+ l2v2_world<T, NG, NP, NC, NR>(m2, sh.o.g, sh.o.k, in, fric, h, rec, nefc_out, lane, tmr_l2);
50
+ }
51
+
52
+ } // namespace js::soft::gpu