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,490 @@
1
+ #pragma once
2
+ // D16 L1 (2026-11-02): kernel P without collision. The soft law's smooth dynamics of one world per 32-thread
3
+ // block, in MuJoCo's coordinates, lane-parallel (docs: the L1_INTERFACE.md; prediction and gates: tools/d16/L1_PREDICTION.md).
4
+ // Templated on the scalar T: float (production) and double (the f64 build that gates correctness against core/soft/kin.h).
5
+ //
6
+ // p_world (the device function the k_pre calls). Its outputs: SharedP's live block (qvel, poses, dof axes) and, when a
7
+ // hand pointer is given, the hand's smooth block in global memory (core/soft/hand.h: M unfactored and dense, qfrc_smooth,
8
+ // qacc_smooth, clamp):
9
+ // DOWN (a) one root-to-leaf level pass, lane b = body b: the pose (explicitly rounded, core/soft/gpu/fk_rn.cuh: the
10
+ // adjoint's replay calls the same functions and reproduces the bits; the hinge rotation computed before the pass)
11
+ // and, at qacc = 0 with the base acceleration -gravity, the body's angular velocity / acceleration and origin
12
+ // acceleration; nothing else rides the level chain
13
+ // JFN (b) every body at once, from its own registers: its spatial inertia about O (the root's position, read from
14
+ // qpos), its Newton-Euler force, and its moment about O; written transposed (numbers x bodies) into shared memory
15
+ // UP the subtree sums, transposed: lane c holds number c of every body in registers and adds each body into its
16
+ // parent, children before parents (the parent an immediate): a fixed order. All forces are about O (MuJoCo's cfrc
17
+ // convention), so these are plain sums
18
+ // ROWS each dof's motion about O once (lane per dof, into shared); M's sparse rows (each row's <= 16 ancestors, walked by
19
+ // mask) in registers, then packed into shared memory over the dead scratch; the hand's DENSE M written coalesced
20
+ // from it through a per-lane packed slot table (zeros off the pattern); qfrc_bias_i = S_i . (N, F) about O
21
+ // ACT lane u = actuator u: f = kp ctrl - kp q - kd qvel, clipped to forcerange, clamp bit iff f <= lo || f >= hi
22
+ // (step.h); the dof mask OR-reduced by shuffles (exact in any order)
23
+ // SOLVE qfrc_smooth = act - bias; the tree-sparse factor M = L' D L and solve (core/soft/gpu/tree_m.cuh: 16 height levels,
24
+ // no fill-in, ordered sums) for qacc_smooth
25
+ // The global wrapper kernel_p (L1's gate) calls p_world, then writes its extra fields after the hand's words.
26
+ // Determinism: fixed lane ownership, every sum in a fixed order by one lane, no atomics, no counters.
27
+ // Techniques: one world per warp, the level passes and the explicit roundings follow NablaEngine (its paper and source at
28
+ // 70d0c8c, as read; fk_rn.cuh carries the translated parts and their notice); the coordinates and conventions (the free
29
+ // joint's dofs, cdof / cfrc about one point, the M = L' D L factor) are MuJoCo 3.16.0's.
30
+ // The model header (generated by tools/d16/l1_gen.py) must be included first and its namespace named by D16_MODEL_NS.
31
+ #include <cstdint>
32
+ #include <type_traits>
33
+
34
+ #include "../hand.h" // the hand: the smooth block's offsets (hand_layout)
35
+ #include "fk_rn.cuh" // the explicitly rounded FK both the forward and the adjoint replay call
36
+ #include "tree_m.cuh" // the tree-sparse factor / solve of M
37
+
38
+ #ifndef D16_MODEL_NS
39
+ #error "include the generated model header and define D16_MODEL_NS before kernel_p.cuh"
40
+ #endif
41
+
42
+ namespace d16 {
43
+ namespace kp {
44
+ namespace MD = D16_MODEL_NS;
45
+ using MD::NB; using MD::NQ; using MD::NV; using MD::NU; using MD::NTRI; using MD::MAXD; using MD::ROOT; using MD::MAXA;
46
+ using MD::NNZ;
47
+ static_assert(NB == 32, "lane b = body b");
48
+ static_assert(NV > 32 && NV <= 64, "rows l and l + 32 per lane");
49
+ __host__ __device__ constexpr int TRI(int i, int j) { return i * (i + 1) / 2 + j; }
50
+
51
+ // ---- the hand's smooth block (the hand.h; the contact blocks from conJ on belong to L2) ----
52
+ constexpr js::soft::HandLayout HL = js::soft::hand_layout(NV, 0, 0);
53
+ // ---- L1's gate record: the hand's smooth block, then the gate's own fields from HL.conJ on (words of T; the clamp mask's
54
+ // two words: u32 in a float word, zero-extended u64 in a double word, as hand.h / tape.h) ----
55
+ constexpr int H_M = HL.M, H_SMOOTH = HL.qfrc, H_QACC = HL.qacc, H_MASK = HL.clamp;
56
+ constexpr int H_XPOS = HL.conJ; // [NB][3]
57
+ constexpr int H_XQUAT = H_XPOS + 3 * NB; // [NB][4]
58
+ constexpr int H_DOFAX = H_XQUAT + 4 * NB; // [NV][3] world axis of each dof's motion (free translation: e_k)
59
+ constexpr int H_DOFANC = H_DOFAX + 3 * NV; // [NV][3] the point it rotates about (its body's xpos; free: the root)
60
+ constexpr int H_BIAS = H_DOFANC + 3 * NV; // [NV] qfrc_bias
61
+ constexpr int H_ACT = H_BIAS + NV; // [NV] qfrc_actuator (clipped)
62
+ constexpr int H_WORDS = (H_ACT + NV + 3) / 4 * 4;
63
+
64
+ template <class T> __device__ __forceinline__ void store_mask(T* w, uint32_t m);
65
+ template <> __device__ __forceinline__ void store_mask<float>(float* w, uint32_t m) { *reinterpret_cast<uint32_t*>(w) = m; }
66
+ template <> __device__ __forceinline__ void store_mask<double>(double* w, uint32_t m) {
67
+ *reinterpret_cast<uint64_t*>(w) = static_cast<uint64_t>(m);
68
+ }
69
+
70
+ // plain helpers for what no replay reproduces (dynamics): free to contract
71
+ template <class T> __device__ __forceinline__ void qrot(const T* q, const T* v, T* o) {
72
+ const T tx = T(2) * (q[2] * v[2] - q[3] * v[1]), ty = T(2) * (q[3] * v[0] - q[1] * v[2]), tz = T(2) * (q[1] * v[1] - q[2] * v[0]);
73
+ o[0] = v[0] + q[0] * tx + q[2] * tz - q[3] * ty;
74
+ o[1] = v[1] + q[0] * ty + q[3] * tx - q[1] * tz;
75
+ o[2] = v[2] + q[0] * tz + q[1] * ty - q[2] * tx;
76
+ }
77
+ template <class T> __device__ __forceinline__ void qrot_inv(const T* q, const T* v, T* o) {
78
+ const T qc[4] = {q[0], -q[1], -q[2], -q[3]};
79
+ qrot(qc, v, o);
80
+ }
81
+ template <class T> __device__ __forceinline__ void qmul(const T* a, const T* b, T* o) {
82
+ const T w = a[0] * b[0] - a[1] * b[1] - a[2] * b[2] - a[3] * b[3];
83
+ const T x = a[0] * b[1] + a[1] * b[0] + a[2] * b[3] - a[3] * b[2];
84
+ const T y = a[0] * b[2] - a[1] * b[3] + a[2] * b[0] + a[3] * b[1];
85
+ const T z = a[0] * b[3] + a[1] * b[2] - a[2] * b[1] + a[3] * b[0];
86
+ o[0] = w; o[1] = x; o[2] = y; o[3] = z;
87
+ }
88
+ template <class T> __device__ __forceinline__ void cross(const T* a, const T* b, T* o) {
89
+ o[0] = a[1] * b[2] - a[2] * b[1]; o[1] = a[2] * b[0] - a[0] * b[2]; o[2] = a[0] * b[1] - a[1] * b[0];
90
+ }
91
+ template <class T> __device__ __forceinline__ T dot3(const T* a, const T* b) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; }
92
+
93
+ constexpr int NNZP = (NNZ + 3) / 4 * 4; // the packed sparse M, padded to 16 bytes
94
+ constexpr int NR = 16; // the numbers UP sums per body: J (10), F (3), N about O (3)
95
+ constexpr int NMARK = 7; // D16_L1_TIMERS: clock marks per world (6 phases)
96
+ constexpr int QADR_ROOT = MD::kQadr[ROOT];
97
+ __host__ __device__ constexpr int body_parent(int b) { return MD::kParent[b]; } // constant-expression use only
98
+ // a compile-time loop: f(std::integral_constant<int, I>) for I = B .. E - 1
99
+ template <int I, int E, class F> __device__ __forceinline__ void kfor(F&& f) {
100
+ if constexpr (I < E) {
101
+ f(std::integral_constant<int, I>{});
102
+ kfor<I + 1, E>(f);
103
+ }
104
+ }
105
+
106
+ // ---- per-world shared state. LIVE: what p_world leaves for L2 / k_pre (qvel, poses, dof axes). SCRATCH: dead when
107
+ // p_world returns (L2's geometry may union with it), except that the gate wrapper reads f.bias / f.act after p_world. The
108
+ // union's members in the order of their lifetimes: t (DOWN: the parents' W / AL / A; JFN -> UP -> ROWS: the transposed body
109
+ // block R) -> m.S (ROWS; over t's velocities only, never over R) -> f (the packed M, bias, act, the reciprocal pivots; over
110
+ // m.S and R after ROWS' last read of them). ----
111
+ template <class T> struct alignas(16) SharedP {
112
+ // live at the end of p_world
113
+ T qvel[NV + 1];
114
+ T xpos[NB][3], xquat[NB][4];
115
+ T dofax[NV][3]; // world axis of each dof's motion (free translation: e_k); its anchor is xpos[d_DofBody[dof]]
116
+ // scratch
117
+ T qpos[NQ];
118
+ T qacc[NV + 1]; // qfrc_smooth, then qacc_smooth (also written to the hand)
119
+ uint32_t mask[4]; // the clamp mask in words 0, 1 (also written to the hand)
120
+ union U {
121
+ // R[c][b]: body b's c-th number, transposed (row stride NB + 1: conflict-free both ways). c = 0..9: J about O (xx yy zz
122
+ // xy xz yz, m c, m); 10..12: F; 13..15: N about O. JFN writes each body's own; UP turns them into subtree sums.
123
+ struct { T W[NB][3], AL[NB][3], A[NB][3]; T R[NR][NB + 1]; } t;
124
+ struct { T S[NV][6]; } m; // over t.W / t.AL / t.A
125
+ struct { T Msp[NNZP]; T bias[NV + 1], act[NV + 1], invD[NV + 1]; T invL[8]; } f; // over m.S and t.R
126
+ } u;
127
+ };
128
+ static_assert(6 * NV <= 9 * NB, "m.S must stay clear of t.R");
129
+ template <class T> constexpr int shared_live_bytes() { // the live block, for the k_pre budget
130
+ return static_cast<int>(sizeof(T) * ((NV + 1) + 3 * NB + 4 * NB + 3 * NV));
131
+ }
132
+
133
+ template <class T> __device__ __forceinline__ T val(const T* __restrict__ V, int i) { return __ldg(V + i); }
134
+ // a structure table read by a runtime index: the __device__ copy (global, L1-cached), never the constexpr one
135
+ #define LDI(t, i) __ldg(&MD::d##t[(i)])
136
+
137
+ // the motion of dof i about the point O: w (world angular), v (velocity of O); free translation: (0, e_k)
138
+ template <class T>
139
+ __device__ __forceinline__ void dof_motion(const SharedP<T>& s, const T* __restrict__ V, int i, int b, const T* O, T* w, T* v) {
140
+ if (b == ROOT) {
141
+ const int t = i - MD::ROOT_DADR;
142
+ T e[3] = {T(0), T(0), T(0)};
143
+ if (t < 3) { e[t] = T(1); w[0] = w[1] = w[2] = T(0); v[0] = e[0]; v[1] = e[1]; v[2] = e[2]; return; }
144
+ e[t - 3] = T(1);
145
+ qrot(s.xquat[b], e, w); // MuJoCo's free rotation dofs: the body's local axes (O is the root origin: v = 0)
146
+ v[0] = v[1] = v[2] = T(0);
147
+ return;
148
+ }
149
+ const T ax[3] = {val(V, MD::OFF_AXIS + 3 * b), val(V, MD::OFF_AXIS + 3 * b + 1), val(V, MD::OFF_AXIS + 3 * b + 2)};
150
+ qrot(s.xquat[b], ax, w);
151
+ const T r[3] = {O[0] - s.xpos[b][0], O[1] - s.xpos[b][1], O[2] - s.xpos[b][2]};
152
+ cross(w, r, v);
153
+ }
154
+
155
+ // ROWS: the sparse row i of M (its ancestor-or-self dofs ascending, the diagonal last) into registers vals[MAXA], from the
156
+ // composite inertia of dof i's body b about O (t.R) and the motions S (m.S); am: i's ancestor-or-self mask (0: no row).
157
+ // bias: qfrc_bias_i = S_i . (N, F) of b's subtree about O (MuJoCo's cdof . cfrc).
158
+ template <class T>
159
+ __device__ __forceinline__ void m_row_sparse(const SharedP<T>& s, int i, int b, unsigned long long am, T arm, T* vals,
160
+ T& bias) {
161
+ T n[3] = {T(0), T(0), T(0)}, f[3] = {T(0), T(0), T(0)};
162
+ bias = T(0);
163
+ if (am) {
164
+ const T* wi = s.u.m.S[i];
165
+ const T* vi = s.u.m.S[i] + 3;
166
+ T J[10];
167
+ for (int k = 0; k < 10; ++k) J[k] = s.u.t.R[k][b];
168
+ T hv[3], hw[3];
169
+ cross(J + 6, vi, hv);
170
+ cross(J + 6, wi, hw);
171
+ n[0] = J[0] * wi[0] + J[3] * wi[1] + J[4] * wi[2] + hv[0];
172
+ n[1] = J[3] * wi[0] + J[1] * wi[1] + J[5] * wi[2] + hv[1];
173
+ n[2] = J[4] * wi[0] + J[5] * wi[1] + J[2] * wi[2] + hv[2];
174
+ for (int k = 0; k < 3; ++k) f[k] = J[9] * vi[k] - hw[k];
175
+ const T Fb[3] = {s.u.t.R[10][b], s.u.t.R[11][b], s.u.t.R[12][b]};
176
+ const T Nb[3] = {s.u.t.R[13][b], s.u.t.R[14][b], s.u.t.R[15][b]};
177
+ bias = dot3(wi, Nb) + dot3(vi, Fb);
178
+ }
179
+ unsigned long long m = am;
180
+ #pragma unroll
181
+ for (int a = 0; a < MAXA; ++a) {
182
+ T v = T(0);
183
+ if (m) {
184
+ const int j = __ffsll(static_cast<long long>(m)) - 1; // the ancestors ascending
185
+ m &= m - 1ull;
186
+ v = dot3(s.u.m.S[j], n) + dot3(s.u.m.S[j] + 3, f);
187
+ if (j == i) v += arm;
188
+ }
189
+ vals[a] = v;
190
+ }
191
+ }
192
+
193
+ // One world's kernel P; lane = threadIdx.x & 31. The outputs stay in s (the live block) and, when hand is not null, go to
194
+ // the hand's smooth block (the hand.h: M unfactored and dense, qfrc_smooth, qacc_smooth, clamp). tmr: NMARK clock64 marks
195
+ // (D16_L1_TIMERS builds) or null.
196
+ // An external generalized force per world (the muscle stage k_mus runs before k_pre and writes tau_mus [NV]; the request,
197
+ // 2026-11-02, F_ITEM2_DESIGN.md section 3): added in the PD actuators' slot, qfrc_smooth = (act + tau_ext) - bias, before the
198
+ // solve. A compile-time policy (core/soft/EXTENSION_HOOKS.md's rule): the default NoTauExt compiles out, so the G1 build's
199
+ // SASS is unchanged function by function (tools/d16/sass_same.py).
200
+ struct NoTauExt {};
201
+ template <class T> struct TauExt { const T* __restrict__ tau; }; // this world's [NV], read once at p_world's start
202
+ #ifdef D16_G1_COMDR
203
+ // COMDR (tools/g1_seconds/COMDR_DESIGN.md, deck-only): this world's CoM offset [3] for ONE body (the G1's anchor, torso_link): that
204
+ // body's ipos += off at the lane load; mass, inertia, iquat unchanged; no external force. Compiled only under -DD16_G1_COMDR
205
+ // (soft_engine.load_ext(comdr=True)), so the default build's tokens and SASS are unchanged.
206
+ template <class T> struct ComExt { int body; const T* __restrict__ off; };
207
+ #endif
208
+
209
+ template <class T, class E = NoTauExt>
210
+ __device__ __forceinline__ void p_world(SharedP<T>& s, const T* __restrict__ V, const T* __restrict__ qpos,
211
+ const T* __restrict__ qvel, const T* __restrict__ ctrl, int lane, T* __restrict__ hand,
212
+ long long* tmr, const E& ext = E{}) {
213
+ #ifdef D16_G1_COMDR
214
+ static_assert(std::is_same_v<E, NoTauExt> || std::is_same_v<E, TauExt<T>> || std::is_same_v<E, ComExt<T>>,
215
+ "p_world: the external-force / CoM-offset policy");
216
+ #else
217
+ static_assert(std::is_same_v<E, NoTauExt> || std::is_same_v<E, TauExt<T>>, "p_world: the external-force policy");
218
+ #endif
219
+ #ifdef D16_L1_TIMERS
220
+ #define TMARK(k) do { if (lane == 0 && tmr) tmr[k] = clock64(); } while (0)
221
+ #else
222
+ #define TMARK(k) do { (void)tmr; } while (0)
223
+ #endif
224
+ TMARK(0);
225
+ [[maybe_unused]] T tx0 = T(0), tx1 = T(0); // the external force at dofs lane and lane + 32, loaded off the pose chain
226
+ #ifdef D16_G1_COMDR
227
+ if constexpr (std::is_same_v<E, TauExt<T>>) { // (ComExt carries no external force)
228
+ #else
229
+ if constexpr (!std::is_same_v<E, NoTauExt>) {
230
+ #endif
231
+ if (lane < NV) tx0 = ext.tau[lane];
232
+ if (lane + 32 < NV) tx1 = ext.tau[lane + 32];
233
+ }
234
+ for (int k = lane; k < NQ; k += 32) s.qpos[k] = qpos[k];
235
+ for (int k = lane; k < NV; k += 32) s.qvel[k] = qvel[k];
236
+ const int b = lane, par = LDI(Parent, b), depth = LDI(Depth, b), jt = LDI(Jtype, b);
237
+ const int qadr = LDI(Qadr, b), dadr = LDI(Dadr, b); // read once: no table load inside the level loop
238
+ // the lane's body constants, read once: frame, joint axis, inertial frame, mass, principal inertia
239
+ const T pb[3] = {val(V, MD::OFF_POS + 3 * b), val(V, MD::OFF_POS + 3 * b + 1), val(V, MD::OFF_POS + 3 * b + 2)};
240
+ const T qb[4] = {val(V, MD::OFF_QUAT + 4 * b), val(V, MD::OFF_QUAT + 4 * b + 1), val(V, MD::OFF_QUAT + 4 * b + 2),
241
+ val(V, MD::OFF_QUAT + 4 * b + 3)};
242
+ const T ax[3] = {val(V, MD::OFF_AXIS + 3 * b), val(V, MD::OFF_AXIS + 3 * b + 1), val(V, MD::OFF_AXIS + 3 * b + 2)};
243
+ #ifdef D16_G1_COMDR
244
+ T ip[3] = {val(V, MD::OFF_IPOS + 3 * b), val(V, MD::OFF_IPOS + 3 * b + 1), val(V, MD::OFF_IPOS + 3 * b + 2)};
245
+ if constexpr (std::is_same_v<E, ComExt<T>>) { // the anchor's CoM offset for this world (the lane's body is b)
246
+ if (b == ext.body) { ip[0] += ext.off[0]; ip[1] += ext.off[1]; ip[2] += ext.off[2]; }
247
+ }
248
+ #else
249
+ const T ip[3] = {val(V, MD::OFF_IPOS + 3 * b), val(V, MD::OFF_IPOS + 3 * b + 1), val(V, MD::OFF_IPOS + 3 * b + 2)};
250
+ #endif
251
+ const T iq[4] = {val(V, MD::OFF_IQUAT + 4 * b), val(V, MD::OFF_IQUAT + 4 * b + 1), val(V, MD::OFF_IQUAT + 4 * b + 2),
252
+ val(V, MD::OFF_IQUAT + 4 * b + 3)};
253
+ const T bmass = val(V, MD::OFF_MASS + b);
254
+ const T bI[3] = {val(V, MD::OFF_INERT + 3 * b), val(V, MD::OFF_INERT + 3 * b + 1), val(V, MD::OFF_INERT + 3 * b + 2)};
255
+ const T g[3] = {val(V, MD::OFF_GRAV), val(V, MD::OFF_GRAV + 1), val(V, MD::OFF_GRAV + 2)};
256
+ auto& t = s.u.t;
257
+ if (b == 0) { // the world: at rest, the base acceleration -gravity
258
+ s.xpos[0][0] = s.xpos[0][1] = s.xpos[0][2] = T(0);
259
+ s.xquat[0][0] = T(1); s.xquat[0][1] = s.xquat[0][2] = s.xquat[0][3] = T(0);
260
+ for (int k = 0; k < 3; ++k) { t.W[0][k] = T(0); t.AL[0][k] = T(0); t.A[0][k] = -g[k]; }
261
+ }
262
+ __syncwarp();
263
+ const T O[3] = {s.qpos[QADR_ROOT], s.qpos[QADR_ROOT + 1], s.qpos[QADR_ROOT + 2]}; // = xpos[ROOT], bitwise
264
+ // the hinge's local rotation and rate, off the pose chain (hinge_quat_rn: fk_child_rn's own operations)
265
+ T ha[4] = {T(1), T(0), T(0), T(0)}, qd = T(0);
266
+ if (jt == 3) {
267
+ hinge_quat_rn(s.qpos[qadr], ax, ha);
268
+ qd = s.qvel[dadr];
269
+ }
270
+ // ---------------- DOWN (a): the level loop: pose and kinematics at qacc = 0, nothing else ----------------
271
+ T Q[4] = {T(1), T(0), T(0), T(0)}, X[3] = {T(0), T(0), T(0)};
272
+ T W[3] = {T(0), T(0), T(0)}, AL[3] = {T(0), T(0), T(0)}, A[3] = {-g[0], -g[1], -g[2]};
273
+ for (int d = 1; d <= MAXD; ++d) {
274
+ if (depth == d) {
275
+ if (jt == 0) {
276
+ fk_free_rn(s.qpos + qadr, X, Q);
277
+ } else {
278
+ fk_child_ha_rn(s.xpos[par], s.xquat[par], pb, qb, jt == 3, ha, X, Q);
279
+ }
280
+ for (int k = 0; k < 3; ++k) s.xpos[b][k] = X[k];
281
+ for (int k = 0; k < 4; ++k) s.xquat[b][k] = Q[k];
282
+ if (jt == 0) {
283
+ qrot(Q, s.qvel + dadr + 3, W);
284
+ } else if (jt == 3) {
285
+ const T* Wp = t.W[par]; const T* ALp = t.AL[par]; const T* Ap = t.A[par];
286
+ T r[3], u1[3], u2[3], wr[3], awd[3], aw[3];
287
+ qrot(Q, ax, aw);
288
+ for (int k = 0; k < 3; ++k) { r[k] = X[k] - s.xpos[par][k]; awd[k] = aw[k] * qd; W[k] = Wp[k] + awd[k]; }
289
+ cross(Wp, awd, u2);
290
+ for (int k = 0; k < 3; ++k) AL[k] = ALp[k] + u2[k];
291
+ cross(ALp, r, u1);
292
+ cross(Wp, r, wr);
293
+ cross(Wp, wr, u2);
294
+ for (int k = 0; k < 3; ++k) A[k] = Ap[k] + u1[k] + u2[k];
295
+ } // a static body (the terrain): at rest (W = AL = 0, A = -g), no mass, no children
296
+ for (int k = 0; k < 3; ++k) { t.W[b][k] = W[k]; t.AL[b][k] = AL[k]; t.A[b][k] = A[k]; }
297
+ }
298
+ __syncwarp();
299
+ }
300
+ TMARK(1);
301
+ // ROWS' per-lane tables, issued here: hidden behind JFN and UP
302
+ const int i0 = lane, i1 = lane + 32;
303
+ const bool has1 = i1 < NV;
304
+ const int db0 = LDI(DofBody, i0), db1 = has1 ? LDI(DofBody, i1) : 0;
305
+ const unsigned long long am0 = LDI(AncMask, i0), am1 = has1 ? LDI(AncMask, i1) : 0ull;
306
+ const int ro0 = LDI(RowOff, i0), ro1 = has1 ? LDI(RowOff, i1) : 0;
307
+ const T arm0 = val(V, MD::OFF_ARM + i0), arm1 = has1 ? val(V, MD::OFF_ARM + i1) : T(0);
308
+ uint32_t d2s[MD::ND2SW];
309
+ #pragma unroll
310
+ for (int w = 0; w < MD::ND2SW; ++w) d2s[w] = LDI(D2SP, 32 * w + lane);
311
+ // ---------------- DOWN (b), JFN: every body at once, from its own registers: its inertia about O, its force, its moment
312
+ // about O; written transposed into t.R ----------------
313
+ {
314
+ T J[10], F[3] = {T(0), T(0), T(0)}, N[3] = {T(0), T(0), T(0)};
315
+ for (int k = 0; k < 10; ++k) J[k] = T(0);
316
+ if (bmass > T(0) && jt != -1) {
317
+ const T m = bmass;
318
+ T qi[4], R[9], c[3], cvec[3];
319
+ qmul(Q, iq, qi);
320
+ for (int k = 0; k < 3; ++k) {
321
+ T e[3] = {T(0), T(0), T(0)};
322
+ e[k] = T(1);
323
+ qrot(qi, e, R + 3 * k); // column k of the inertia frame
324
+ }
325
+ J[0] = bI[0] * R[0] * R[0] + bI[1] * R[3] * R[3] + bI[2] * R[6] * R[6];
326
+ J[1] = bI[0] * R[1] * R[1] + bI[1] * R[4] * R[4] + bI[2] * R[7] * R[7];
327
+ J[2] = bI[0] * R[2] * R[2] + bI[1] * R[5] * R[5] + bI[2] * R[8] * R[8];
328
+ J[3] = bI[0] * R[0] * R[1] + bI[1] * R[3] * R[4] + bI[2] * R[6] * R[7];
329
+ J[4] = bI[0] * R[0] * R[2] + bI[1] * R[3] * R[5] + bI[2] * R[6] * R[8];
330
+ J[5] = bI[0] * R[1] * R[2] + bI[1] * R[4] * R[5] + bI[2] * R[7] * R[8];
331
+ qrot(Q, ip, cvec); // the COM offset from the body origin, world frame
332
+ for (int k = 0; k < 3; ++k) c[k] = X[k] + cvec[k] - O[k];
333
+ const T cc = dot3(c, c);
334
+ J[0] += m * (cc - c[0] * c[0]); J[1] += m * (cc - c[1] * c[1]); J[2] += m * (cc - c[2] * c[2]);
335
+ J[3] -= m * c[0] * c[1]; J[4] -= m * c[0] * c[2]; J[5] -= m * c[1] * c[2];
336
+ J[6] = m * c[0]; J[7] = m * c[1]; J[8] = m * c[2]; J[9] = m;
337
+ // Newton-Euler at the COM, moved to the body origin: F = m a_c, N = I al + w x I w + cvec x F; then about O
338
+ T u[3], u2[3], wc[3], l[3], Iw[3], Ia[3], cf[3], xo[3];
339
+ cross(AL, cvec, u);
340
+ cross(W, cvec, wc);
341
+ cross(W, wc, u2);
342
+ for (int k = 0; k < 3; ++k) F[k] = m * (A[k] + u[k] + u2[k]);
343
+ qrot_inv(qi, W, l);
344
+ for (int k = 0; k < 3; ++k) l[k] *= bI[k];
345
+ qrot(qi, l, Iw);
346
+ qrot_inv(qi, AL, l);
347
+ for (int k = 0; k < 3; ++k) l[k] *= bI[k];
348
+ qrot(qi, l, Ia);
349
+ cross(W, Iw, u);
350
+ cross(cvec, F, cf);
351
+ for (int k = 0; k < 3; ++k) { N[k] = Ia[k] + u[k] + cf[k]; xo[k] = X[k] - O[k]; }
352
+ cross(xo, F, u);
353
+ for (int k = 0; k < 3; ++k) N[k] += u[k];
354
+ }
355
+ for (int k = 0; k < 10; ++k) t.R[k][b] = J[k];
356
+ for (int k = 0; k < 3; ++k) { t.R[10 + k][b] = F[k]; t.R[13 + k][b] = N[k]; }
357
+ }
358
+ __syncwarp();
359
+ TMARK(2);
360
+ // ---------------- UP: subtree sums, transposed: lane c < NR holds number c of every body in registers and adds each body
361
+ // into its parent, children before parents (reverse body order; the parent an immediate): a fixed order ----------------
362
+ if (lane < NR) {
363
+ T S[NB];
364
+ #pragma unroll
365
+ for (int bb = 0; bb < NB; ++bb) S[bb] = t.R[lane][bb];
366
+ kfor<0, NB - 1>([&](auto ic) {
367
+ constexpr int bb = NB - 1 - decltype(ic)::value, pp = body_parent(bb);
368
+ S[pp] += S[bb];
369
+ });
370
+ #pragma unroll
371
+ for (int bb = 0; bb < NB; ++bb) t.R[lane][bb] = S[bb];
372
+ }
373
+ __syncwarp();
374
+ TMARK(3);
375
+ // ---------------- ROWS: the dof motions (over t's velocities), M's sparse rows and qfrc_bias (packed over S / R) -------
376
+ {
377
+ T wi[3], vi[3];
378
+ dof_motion(s, V, i0, db0, O, wi, vi);
379
+ for (int k = 0; k < 3; ++k) { s.u.m.S[i0][k] = wi[k]; s.u.m.S[i0][3 + k] = vi[k]; }
380
+ const bool trans0 = db0 == ROOT && i0 - MD::ROOT_DADR < 3;
381
+ for (int k = 0; k < 3; ++k) s.dofax[i0][k] = trans0 ? (k == i0 - MD::ROOT_DADR ? T(1) : T(0)) : wi[k];
382
+ if (has1) {
383
+ dof_motion(s, V, i1, db1, O, wi, vi);
384
+ for (int k = 0; k < 3; ++k) { s.u.m.S[i1][k] = wi[k]; s.u.m.S[i1][3 + k] = vi[k]; }
385
+ for (int k = 0; k < 3; ++k) s.dofax[i1][k] = wi[k]; // a hinge: dof >= 32 is never the free joint's
386
+ }
387
+ }
388
+ __syncwarp();
389
+ T v0[MAXA], v1[MAXA], bias0, bias1;
390
+ m_row_sparse(s, i0, db0, am0, arm0, v0, bias0);
391
+ m_row_sparse(s, i1, db1, am1, arm1, v1, bias1);
392
+ __syncwarp(); // every lane's reads of m.S and t.R are done: f overlays them
393
+ auto& f = s.u.f;
394
+ {
395
+ const int na0 = __popcll(am0), na1 = __popcll(am1);
396
+ #pragma unroll
397
+ for (int a = 0; a < MAXA; ++a) {
398
+ if (a < na0) f.Msp[ro0 + a] = v0[a];
399
+ if (a < na1) f.Msp[ro1 + a] = v1[a];
400
+ }
401
+ }
402
+ f.bias[i0] = bias0;
403
+ if (has1) f.bias[i1] = bias1;
404
+ for (int k = lane; k < NV; k += 32) f.act[k] = T(0);
405
+ __syncwarp();
406
+ if (hand) { // the hand's dense M, unfactored, coalesced (zeros off the tree pattern), slots from the per-lane packed table
407
+ #pragma unroll
408
+ for (int r = 0; r < MD::ND2SR; ++r) {
409
+ const int k = lane + 32 * r;
410
+ if (k < NTRI) {
411
+ const uint32_t sl = (d2s[r >> 1] >> (16 * (r & 1))) & 0xFFFFu;
412
+ hand[H_M + k] = sl != 0xFFFFu ? f.Msp[sl] : T(0);
413
+ }
414
+ }
415
+ }
416
+ TMARK(4);
417
+ // ---------------- ACT: actuators (MuJoCo actuator order -> dofs), the clamp mask, qfrc_smooth ----------------
418
+ uint32_t m0 = 0u, m1 = 0u;
419
+ if (lane < NU) {
420
+ const int dof = LDI(ActDof, lane);
421
+ const T kpv = val(V, MD::OFF_KP + lane), kdv = val(V, MD::OFF_KD + lane);
422
+ const T lo = val(V, MD::OFF_FLO + lane), hi = val(V, MD::OFF_FHI + lane);
423
+ T fa = kpv * ctrl[lane] - kpv * s.qpos[dof + 1] - kdv * s.qvel[dof]; // a hinge dof's coordinate is qpos[dof + 1]
424
+ const bool clamped = fa <= lo || fa >= hi;
425
+ fa = fa < lo ? lo : (fa > hi ? hi : fa);
426
+ f.act[dof] = fa;
427
+ if (clamped) { if (dof < 32) m0 = 1u << dof; else m1 = 1u << (dof - 32); }
428
+ }
429
+ for (int o = 16; o > 0; o >>= 1) { // OR is exact: the order cannot change the bits
430
+ m0 |= __shfl_xor_sync(0xffffffffu, m0, o);
431
+ m1 |= __shfl_xor_sync(0xffffffffu, m1, o);
432
+ }
433
+ if (lane == 0) {
434
+ s.mask[0] = m0; s.mask[1] = m1; s.mask[2] = 0u; s.mask[3] = 0u;
435
+ if (hand) { store_mask(hand + H_MASK, m0); store_mask(hand + H_MASK + 1, m1); }
436
+ }
437
+ __syncwarp();
438
+ for (int k = lane; k < NV; k += 32) {
439
+ #ifdef D16_G1_COMDR
440
+ if constexpr (!std::is_same_v<E, TauExt<T>>) {
441
+ #else
442
+ if constexpr (std::is_same_v<E, NoTauExt>) {
443
+ #endif
444
+ s.qacc[k] = f.act[k] - f.bias[k]; // qfrc_smooth: the solve's right-hand side
445
+ } else {
446
+ s.qacc[k] = (f.act[k] + (k < 32 ? tx0 : tx1)) - f.bias[k]; // the external force in the actuators' slot
447
+ }
448
+ if (hand) hand[H_SMOOTH + k] = s.qacc[k];
449
+ }
450
+ __syncwarp();
451
+ TMARK(5);
452
+ // ---------------- SOLVE: the tree-sparse factor in place and qacc_smooth ----------------
453
+ tree::factor(f.Msp, f.invD, f.invL, lane);
454
+ tree::solve(f.Msp, f.invD, s.qacc, lane);
455
+ if (hand)
456
+ for (int k = lane; k < NV; k += 32) hand[H_QACC + k] = s.qacc[k];
457
+ TMARK(6);
458
+ #undef TMARK
459
+ }
460
+
461
+ #ifndef D16_L1_MINB
462
+ #define D16_L1_MINB 16
463
+ #endif
464
+ // L1's gate wrapper: p_world (writing the hand's smooth block), then the gate's own fields from shared memory; the record's
465
+ // words the hand reserves for others (the M block's alignment tail, the counts and their padding) are zeroed, so two runs
466
+ // compare bitwise on the whole record
467
+ template <class T>
468
+ __global__ void __launch_bounds__(32, D16_L1_MINB)
469
+ kernel_p(const T* __restrict__ V, const T* __restrict__ qpos, const T* __restrict__ qvel, const T* __restrict__ ctrl,
470
+ T* __restrict__ hand, long long* __restrict__ tmr, int n_world) {
471
+ __shared__ SharedP<T> s;
472
+ const int w = blockIdx.x;
473
+ if (w >= n_world) return;
474
+ const int lane = threadIdx.x & 31;
475
+ T* h = hand + static_cast<long>(w) * H_WORDS;
476
+ p_world<T>(s, V, qpos + static_cast<long>(w) * NQ, qvel + static_cast<long>(w) * NV, ctrl + static_cast<long>(w) * NU, lane,
477
+ h, tmr ? tmr + static_cast<long>(NMARK) * w : nullptr);
478
+ for (int k = NTRI + lane; k < H_SMOOTH; k += 32) h[k] = T(0);
479
+ for (int k = H_MASK + 2 + lane; k < H_XPOS; k += 32) h[k] = T(0);
480
+ for (int k = lane; k < 3 * NB; k += 32) h[H_XPOS + k] = (&s.xpos[0][0])[k];
481
+ for (int k = lane; k < 4 * NB; k += 32) h[H_XQUAT + k] = (&s.xquat[0][0])[k];
482
+ for (int k = lane; k < 3 * NV; k += 32) {
483
+ h[H_DOFAX + k] = (&s.dofax[0][0])[k];
484
+ h[H_DOFANC + k] = s.xpos[LDI(DofBody, k / 3)][k % 3];
485
+ }
486
+ for (int k = lane; k < NV; k += 32) { h[H_BIAS + k] = s.u.f.bias[k]; h[H_ACT + k] = s.u.f.act[k]; }
487
+ }
488
+
489
+ } // namespace kp
490
+ } // namespace d16