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,1038 @@
1
+ #pragma once
2
+ // D16 muscle stage on the GPU (agent F, item 4; ITEM4_PREDICTION.md): k_mus (the forward) and muscle_adj (its VJP), one
3
+ // warp per world. Both run core/soft/muscle.h's lane functions unchanged on a shared table of relative poses.
4
+ //
5
+ // The slot table. Slot 0 is the identity. Slots 1.. are the (L, b) poses a muscle needs, where L is the muscle's lowest
6
+ // common ancestor body and b a body on the path from L down to one of its sites. They are ordered by level, so a level's
7
+ // slots depend only on earlier levels. Each is composed exactly as kin::forward_kinematics composes a body:
8
+ // pose = parent o (pos_tree, quat_tree) o joint(q).
9
+ // The generator remaps every muscle's site and joint-entry "body" index to its slot, so muscle.h indexes this table as it
10
+ // indexes a pose array. Precision: each muscle's geometry lives in its LCA's frame (F_ITEM2_DESIGN.md section 2, f32).
11
+ //
12
+ // tau's reduction is a fixed-order gather. Per round of 32 muscles, each lane stages F r_k; then lane = dof subtracts its
13
+ // staged products in round, lane, slot order, i.e. muscle order, the CPU reference's summation order. No atomics.
14
+ // No device asserts in production: the library is built with -DNDEBUG; host-side checks guard the sizes.
15
+ //
16
+ // The law (2026-11-05; tools/d16_x14adj/MILLARD14.md): a build with -DD16_X14_MILLARD runs core/soft/muscle.h's Millard 2013
17
+ // fibre (section 4m) in place of the Geyer one at the three fibre calls below (k_mus_body, muscle_adj_body, k_mus_equil); the
18
+ // staging, rounds, tape and geometry are the same code. Without it the preprocessed source is today's, so the Geyer kernels'
19
+ // SASS is unchanged (gate 1).
20
+ #include <type_traits>
21
+
22
+ #include "diffneusim/macros.h"
23
+ #include "../../math/so3.h"
24
+ #include "../../kin/kinematic_tree.h"
25
+ #include "../../diff/dual.h"
26
+ #include "../muscle.h"
27
+ #include "../tape.h"
28
+ #include "model_view.cuh"
29
+
30
+ namespace js::soft::gpu {
31
+
32
+ // Test builds only (-DF_KMUS_PROF): per (world, lane), the clock64 cycles spent in each phase, accumulated over the
33
+ // rounds: mark i adds the time since the previous mark to phase i. Written to [n_worlds][32][kProfMarks] at the end.
34
+ // Production builds define the macros as nothing, so their SASS is unchanged.
35
+ constexpr int kProfMarks = 12;
36
+ #ifdef F_KMUS_PROF
37
+ __device__ long long* g_mus_prof = nullptr;
38
+ __device__ void* g_adj_F = nullptr; // muscle_adj's recomputed F [n_worlds][NM] (the primal-consistency check of fix 3)
39
+ #define F_PROF_DECL long long f_prof_acc[kProfMarks] = {}; long long f_prof_t = clock64()
40
+ #define F_PROF_MARK(i) do { const long long f_now = clock64(); f_prof_acc[i] += f_now - f_prof_t; f_prof_t = f_now; } while (0)
41
+ #define F_PROF_STORE do { if (g_mus_prof) { _Pragma("unroll") for (int f_i = 0; f_i < kProfMarks; ++f_i) \
42
+ g_mus_prof[(static_cast<long>(blockIdx.x) * 32 + threadIdx.x) * kProfMarks + f_i] = f_prof_acc[f_i]; } } while (0)
43
+ #else
44
+ #define F_PROF_DECL do {} while (0)
45
+ #define F_PROF_MARK(i) do {} while (0)
46
+ #define F_PROF_STORE do {} while (0)
47
+ #endif
48
+
49
+ // The 416's muscle classes (2026-11-08; tools/d16_bodies/MUSCLE_SPLIT.md, the review R1 / R3). A body header that defines
50
+ // D16_BODY_MUS_SPLIT runs the stage as two class kernels (narrow, then wide):
51
+ // - each loops over its class's NMC muscles (its MusSlots perm holds global muscle ids), while every stride, tape word and per-muscle index stays global (NM);
52
+ // - with ACC_IN it starts its accumulator from what the class before it left (tau in the forward, q_bar in the adjoint) and continues that running sum in its
53
+ // own order, so the two kernels equal one kernel on the reordered perm (the bitwise control).
54
+ // Without the macro these expand to the original tokens (KMUS_P / KMUS_A wrap the last parameter or argument, so no empty expansion changes the spacing), so the 14x's (and every other body's) preprocessed source is unchanged.
55
+ #define D16_KMUS_INCLUDED 1 // a muscle-split body header must come before this file (gen_body.py --mus-split checks it)
56
+ #if defined(D16_BODY_MUS_SPLIT)
57
+ #define KMUS_P(x) x, int NMC = NM, bool ACC_IN = false
58
+ #define KMUS_A(x) x, NMC, ACC_IN
59
+ #define KMUS_NMC NMC
60
+ #define KMUS_ACC0(x) (ACC_IN ? (x) : T(0))
61
+ #else
62
+ #define KMUS_P(x) x
63
+ #define KMUS_A(x) x
64
+ #define KMUS_NMC NM
65
+ #define KMUS_ACC0(x) T(0)
66
+ #endif
67
+
68
+ template <class P> struct MusSlots {
69
+ int nslot = 0, nlev = 0;
70
+ const int* lev_off; // [nlev + 1] slots of each level (slot 0, the identity, is in none)
71
+ const int* parent; // [nslot] the parent's slot (0 = L itself)
72
+ const int* kjt; // [nslot] kin::JointType of the slot's body
73
+ const int* qadr; // [nslot]
74
+ const int* vadr; // [nslot] the joint's first dof (the ball term)
75
+ const int* cpl_qadr; // [nslot] coupled: the master's q index, else -1
76
+ const P* cpl_coef; // [5 nslot]
77
+ const P* axis; // [3 nslot] (the joint axis in the body frame)
78
+ const P* pos; // [3 nslot] pos_tree
79
+ const P* quat; // [4 nslot] quat_tree
80
+ int nround = 0;
81
+ const int* g_off; // [nround nv + 1] the tau / q_bar gather, per (round, dof)
82
+ const int* g_ent; // staging index lane * KD + k
83
+ int nseed = 0;
84
+ const int* seed; // [3 nseed] (kin jtype, qadr, vadr): the q chart (integrate_pos) for the tangent pass
85
+ const int* perm; // [nm] the rounds' fixed muscle order (step 2a: cost-sorted); per-muscle data keeps its index
86
+ const int4* erec_i; // [nje] fix 5 (i): the per-entry records (row_ms_rec)
87
+ const P* erec_f; // [8 nje]
88
+ };
89
+
90
+ // Step 2b (ITEM4_FASTFK_PREREG.md), NOT adopted: with -DF_MUS_FASTFK, a hinge's rotation via __sincosf and quaternion
91
+ // normalization via rsqrtf on the device in f32. It fails G3 on the 14x (dF / F_max 2.3e-4 > 2e-4), so the default is
92
+ // kin::joint_transform / so3::quat_normalize everywhere.
93
+ template <class S>
94
+ __device__ __forceinline__ void mus_joint_transform(kin::JointType jt, so3::Vec3<S> ax, const S* q, so3::Quat<S>& R, so3::Vec3<S>& p) {
95
+ kin::joint_transform(jt, ax, q, R, p);
96
+ }
97
+ template <class S> __device__ __forceinline__ so3::Quat<S> mus_qnormalize(so3::Quat<S> q) { return so3::quat_normalize(q); }
98
+ #ifdef F_MUS_FASTFK // NOT adopted: fails G3 on the 14x (ITEM4_FASTFK_PREREG.md); kept opt-in for the record
99
+ template <>
100
+ __device__ __forceinline__ void mus_joint_transform<float>(kin::JointType jt, so3::Vec3<float> ax, const float* q, so3::Quat<float>& R,
101
+ so3::Vec3<float>& p) {
102
+ if (jt == kin::JointType::Revolute) { // unit axes (checked): exp_map(axis q) = (cos(q / 2), sin(q / 2) axis)
103
+ float s, c;
104
+ __sincosf(0.5f * q[0], &s, &c);
105
+ R = {c, s * ax.x, s * ax.y, s * ax.z};
106
+ p = {0.f, 0.f, 0.f};
107
+ return;
108
+ }
109
+ if (jt == kin::JointType::Ball) {
110
+ const float k = rsqrtf(q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]);
111
+ R = {q[0] * k, q[1] * k, q[2] * k, q[3] * k};
112
+ p = {0.f, 0.f, 0.f};
113
+ return;
114
+ }
115
+ kin::joint_transform(jt, ax, q, R, p);
116
+ }
117
+ template <> __device__ __forceinline__ so3::Quat<float> mus_qnormalize<float>(so3::Quat<float> q) {
118
+ const float k = rsqrtf(q.w * q.w + q.x * q.x + q.y * q.y + q.z * q.z);
119
+ return {q.w * k, q.x * k, q.y * k, q.z * k};
120
+ }
121
+ #endif
122
+
123
+ // one slot's relative pose from its parent's (kin::forward_kinematics' composition; coupled_q's polynomial)
124
+ template <class S, class P>
125
+ __device__ __forceinline__ kin::Pose<S> mus_slot_pose(const MusSlots<P>& sl, int s, const S* q, const kin::Pose<S>* pose) {
126
+ using namespace so3;
127
+ Quat<S> Rj; Vec3<S> pj;
128
+ const Vec3<S> ax{S(sl.axis[3 * s]), S(sl.axis[3 * s + 1]), S(sl.axis[3 * s + 2])};
129
+ const kin::JointType jt = static_cast<kin::JointType>(sl.kjt[s]);
130
+ if (sl.cpl_qadr[s] >= 0) {
131
+ const P* c = sl.cpl_coef + 5 * s;
132
+ const S qm = q[sl.cpl_qadr[s]];
133
+ const S qc = S(c[0]) + qm * (S(c[1]) + qm * (S(c[2]) + qm * (S(c[3]) + qm * S(c[4]))));
134
+ mus_joint_transform<S>(jt, ax, &qc, Rj, pj);
135
+ } else {
136
+ mus_joint_transform<S>(jt, ax, q + sl.qadr[s], Rj, pj);
137
+ }
138
+ const Quat<S> qt{S(sl.quat[4 * s]), S(sl.quat[4 * s + 1]), S(sl.quat[4 * s + 2]), S(sl.quat[4 * s + 3])};
139
+ const Vec3<S> pt{S(sl.pos[3 * s]), S(sl.pos[3 * s + 1]), S(sl.pos[3 * s + 2])};
140
+ const Quat<S> R_rel = quat_mul(qt, Rj);
141
+ const Vec3<S> p_rel = add(quat_rotate(qt, pj), pt);
142
+ const kin::Pose<S>& pp = pose[sl.parent[s]];
143
+ return {mus_qnormalize<S>(quat_mul(pp.q, R_rel)), add(quat_rotate(pp.q, p_rel), pp.p)};
144
+ }
145
+
146
+ template <class S, class P>
147
+ __device__ __forceinline__ void mus_rel_fk(const MusSlots<P>& sl, const S* q, kin::Pose<S>* pose, int lane) {
148
+ if (lane == 0) pose[0] = {so3::Quat<S>{S(1), S(0), S(0), S(0)}, so3::Vec3<S>{S(0), S(0), S(0)}};
149
+ __syncwarp();
150
+ for (int lv = 0; lv < sl.nlev; ++lv) {
151
+ for (int s = sl.lev_off[lv] + lane; s < sl.lev_off[lv + 1]; s += 32) pose[s] = mus_slot_pose<S>(sl, s, q, pose);
152
+ __syncwarp();
153
+ }
154
+ }
155
+
156
+ // ---------------------------------------------------------------------------------------------------------------------
157
+ // Fix 5 (i) (ITEM4_LOADTEST_PREREG.md, ITEM4_FIX5_PREREG.md): muscle_row_ms reading one denormalized record per joint
158
+ // entry, int4 {body, mask, slot, jtype | (cpl_qadr + 1) << 8} and 8 values {c1, c2, c3, c4, axis x, y, z, 0}, built by
159
+ // the model build from the same tables. An entry costs one level of independent loads instead of entry -> body ->
160
+ // coefficients. The same arithmetic and order as muscle_row_ms (S is the arithmetic type: T, or Dual for the adjoint's
161
+ // walk; P the tables'). PF = 1 also loads the next entry's record first (it bought nothing in the test; kept off).
162
+ template <class T> struct EntryRecs { const int4* ri; const T* rf; };
163
+ template <class T> struct ERec { int b, mask, slot, jt, cq; T c1, c2, c3, c4, ax, ay, az; };
164
+ template <class T> __device__ __forceinline__ ERec<T> load_erec(const EntryRecs<T>& R, int e) {
165
+ ERec<T> o;
166
+ const int4 i = __ldg(&R.ri[e]);
167
+ o.b = i.x; o.mask = i.y; o.slot = i.z; o.jt = i.w & 0xff; o.cq = (i.w >> 8) - 1;
168
+ if constexpr (sizeof(T) == 4) {
169
+ const float4 f0 = __ldg(reinterpret_cast<const float4*>(R.rf + 8 * e)), f1 = __ldg(reinterpret_cast<const float4*>(R.rf + 8 * e) + 1);
170
+ o.c1 = f0.x; o.c2 = f0.y; o.c3 = f0.z; o.c4 = f0.w; o.ax = f1.x; o.ay = f1.y; o.az = f1.z;
171
+ } else {
172
+ const T* f = R.rf + 8 * e;
173
+ o.c1 = __ldg(f); o.c2 = __ldg(f + 1); o.c3 = __ldg(f + 2); o.c4 = __ldg(f + 3); o.ax = __ldg(f + 4); o.ay = __ldg(f + 5); o.az = __ldg(f + 6);
174
+ }
175
+ return o;
176
+ }
177
+ // Arm R1 (-DF_MUS_SHROW): the row r lives in shared memory and an update indexes it at the runtime slot, in place of
178
+ // row_add / row_axpy's unrolled select over KD slots; the same additions in the same order (bitwise).
179
+ #ifdef F_MUS_SHROW
180
+ constexpr bool kShRow = true;
181
+ #else
182
+ constexpr bool kShRow = false;
183
+ #endif
184
+ template <int KD, class S> __device__ __forceinline__ void rsink_add(S* r, int slot, S v) {
185
+ if constexpr (kShRow) r[slot] = r[slot] + v; else row_add<KD>(r, slot, v);
186
+ }
187
+ template <int KD, class S> __device__ __forceinline__ void rsink_axpy(S* r, int slot, S a, S b) {
188
+ if constexpr (kShRow) r[slot] = r[slot] + a * b; else row_axpy<KD>(r, slot, a, b);
189
+ }
190
+ // one entry's contribution (muscle_row_ms' body), given the group sums of its mask
191
+ template <int KD, class S, class T>
192
+ __device__ __forceinline__ void entry_contrib(const ERec<T>& cur, const kin::Pose<S>* pose, const S* q, const so3::Vec3<S>& Pm,
193
+ const so3::Vec3<S>& Gm, S* r) {
194
+ using V = so3::Vec3<S>;
195
+ const kin::Pose<S>& pb = pose[cur.b];
196
+ S scale = S(1);
197
+ if (cur.cq >= 0) {
198
+ const S qm = q[cur.cq];
199
+ scale = S(cur.c1) + qm * (S(2) * S(cur.c2) + qm * (S(3) * S(cur.c3) + qm * S(4) * S(cur.c4)));
200
+ }
201
+ if (cur.jt == kMJSlide) {
202
+ const V a = so3::quat_rotate(pb.q, V{S(cur.ax), S(cur.ay), S(cur.az)});
203
+ rsink_axpy<KD>(r, cur.slot, scale, so3::dot(a, Gm));
204
+ } else {
205
+ const V mom = so3::sub(Pm, so3::cross(pb.p, Gm));
206
+ if (cur.jt == kMJHinge) {
207
+ const V a = so3::quat_rotate(pb.q, V{S(cur.ax), S(cur.ay), S(cur.az)});
208
+ rsink_axpy<KD>(r, cur.slot, scale, so3::dot(a, mom));
209
+ } else {
210
+ const V ml = so3::quat_rotate(so3::quat_conj(pb.q), mom);
211
+ rsink_add<KD>(r, cur.slot, ml.x); rsink_add<KD>(r, cur.slot + 1, ml.y); rsink_add<KD>(r, cur.slot + 2, ml.z);
212
+ }
213
+ }
214
+ }
215
+ template <int NS, class S>
216
+ __device__ __forceinline__ void group_sums(int mask, int n, const so3::Vec3<S>* p, const so3::Vec3<S>* g, so3::Vec3<S>& Pm, so3::Vec3<S>& Gm) {
217
+ Pm = so3::Vec3<S>{S(0), S(0), S(0)}; Gm = so3::Vec3<S>{S(0), S(0), S(0)};
218
+ JS_MUS_UNROLL
219
+ for (int j = 0; j < NS; ++j)
220
+ if (j < n && ((mask >> j) & 1)) { Pm = so3::add(Pm, so3::cross(p[j], g[j])); Gm = so3::add(Gm, g[j]); }
221
+ }
222
+
223
+ template <int NS, int KD, int PF, class S, class T, class MV>
224
+ __device__ __forceinline__ int row_ms_rec(const MuscleTables<T>& t, const MV& mv, const EntryRecs<T>& R, const kin::Pose<S>* pose,
225
+ const S* q, int m, const so3::Vec3<S>* p, const so3::Vec3<S>* g, int n, S* r) {
226
+ using V = so3::Vec3<S>;
227
+ const int nd = t.row_off[m + 1] - t.row_off[m];
228
+ JS_MUS_UNROLL
229
+ for (int k = 0; k < KD; ++k)
230
+ if (k < nd) r[k] = S(0);
231
+ int last = -1;
232
+ V Pm{S(0), S(0), S(0)}, Gm{S(0), S(0), S(0)};
233
+ const int e0 = t.jent_off[m], e1 = t.jent_off[m + 1];
234
+ #ifdef F_MUS_ILP2
235
+ // Arm R2: entries in pairs, the odd ones into a second row, summed in a fixed order at the end (a reassociation)
236
+ S r1[KD];
237
+ JS_MUS_UNROLL
238
+ for (int k = 0; k < KD; ++k) r1[k] = S(0);
239
+ for (int e = e0; e < e1; e += 2) {
240
+ const bool hb = e + 1 < e1;
241
+ const ERec<T> A = load_erec<T>(R, e);
242
+ const ERec<T> B = hb ? load_erec<T>(R, e + 1) : A;
243
+ if (A.mask != last) { group_sums<NS>(A.mask, n, p, g, Pm, Gm); last = A.mask; }
244
+ const V PA = Pm, GA = Gm;
245
+ if (hb && B.mask != last) { group_sums<NS>(B.mask, n, p, g, Pm, Gm); last = B.mask; }
246
+ entry_contrib<KD>(A, pose, q, PA, GA, r);
247
+ if (hb) entry_contrib<KD>(B, pose, q, Pm, Gm, r1);
248
+ }
249
+ JS_MUS_UNROLL
250
+ for (int k = 0; k < KD; ++k)
251
+ if (k < nd) r[k] = r[k] + r1[k];
252
+ #else
253
+ ERec<T> cur;
254
+ if (PF && e0 < e1) cur = load_erec<T>(R, e0);
255
+ for (int e = e0; e < e1; ++e) {
256
+ ERec<T> nxt;
257
+ if (PF) { if (e + 1 < e1) nxt = load_erec<T>(R, e + 1); }
258
+ else cur = load_erec<T>(R, e);
259
+ if (cur.mask != last) { group_sums<NS>(cur.mask, n, p, g, Pm, Gm); last = cur.mask; }
260
+ entry_contrib<KD>(cur, pose, q, Pm, Gm, r);
261
+ if (PF) cur = nxt;
262
+ }
263
+ #endif
264
+ const int s0 = t.site_off[m];
265
+ JS_MUS_UNROLL
266
+ for (int j = 0; j < NS; ++j) {
267
+ if (j >= n) continue;
268
+ const int s = s0 + j;
269
+ if (!t.site_moving[s]) continue;
270
+ const T* c = t.site_coef + 15 * s;
271
+ const S th = q[t.site_cdof_q[s]];
272
+ S dx = S(4) * S(mv.at(kFieldMuscleSite, c + 12)), dy = S(4) * S(mv.at(kFieldMuscleSite, c + 13)),
273
+ dz = S(4) * S(mv.at(kFieldMuscleSite, c + 14));
274
+ for (int k = 3; k >= 1; --k) {
275
+ dx = dx * th + S(k) * S(mv.at(kFieldMuscleSite, c + 3 * k));
276
+ dy = dy * th + S(k) * S(mv.at(kFieldMuscleSite, c + 3 * k + 1));
277
+ dz = dz * th + S(k) * S(mv.at(kFieldMuscleSite, c + 3 * k + 2));
278
+ }
279
+ const V slide = so3::quat_rotate(pose[t.site_body[s]].q, V{dx, dy, dz});
280
+ rsink_add<KD>(r, t.site_slot[s], so3::dot(g[j], slide));
281
+ }
282
+ return nd;
283
+ }
284
+
285
+ #if defined(D16_X14_ROWCF) && !defined(D16_BODY_ROW_CF) // (PREREG_X14ROWCF.md, the review) the first consumer checks the 14x's mapping happened
286
+ #error "D16_X14_ROWCF without D16_BODY_ROW_CF: include soft/gpu/x14_rowcf.h (body14.cuh's 14x branch does) before k_mus.cuh"
287
+ #endif
288
+ #if defined(D16_BODY_ROW_CF)
289
+ // The row's closed-form group sums (2026-11-08; tools/d16_bodies/rowcf/PREREG_ROWCF.md, the review of ROW_PHASE.md). path_grad's g_j is
290
+ // u_(j-1) - u_j (u_s the unit vector of segment s, u_(-1) = u_(n-1) = 0) and p_j x u_(j-1) = p_(j-1) x u_(j-1), so a contiguous prefix or suffix
291
+ // mask's sums telescope to its crossing segment k: Gm = sigma u_k, Pm = sigma p_k x u_k. The record carries (k, sigma) (mus_row_cf.h).
292
+ // muscle_path_units: u_s for s < n - 1, with muscle_path_grad's exact expression per segment; the caller's g[NS] buffer holds them.
293
+ template <int NS, class S>
294
+ __device__ __forceinline__ void muscle_path_units(const so3::Vec3<S>* p, int n, so3::Vec3<S>* u) {
295
+ JS_MUS_UNROLL
296
+ for (int s = 0; s < NS - 1; ++s) {
297
+ if (s < n - 1) {
298
+ so3::Vec3<S> d = so3::sub(p[s + 1], p[s]);
299
+ u[s] = so3::scale(d, gmath::fdiv(S(1), so3::norm(d)));
300
+ }
301
+ }
302
+ }
303
+ // an entry's group sums from its code: k selected over the compile-time sites (registers, no dynamic index), then one cross product
304
+ template <int NS, class S>
305
+ __device__ __forceinline__ void cf_sums(int code, const so3::Vec3<S>* p, const so3::Vec3<S>* u, so3::Vec3<S>& Pm, so3::Vec3<S>& Gm) {
306
+ const int k = code >> 1;
307
+ so3::Vec3<S> pk = p[0], uk = u[0];
308
+ JS_MUS_UNROLL
309
+ for (int j = 1; j < NS - 1; ++j)
310
+ if (j == k) { pk = p[j]; uk = u[j]; }
311
+ const so3::Vec3<S> c = so3::cross(pk, uk);
312
+ if (code & 1) { Gm = so3::scale(uk, S(-1)); Pm = so3::scale(c, S(-1)); }
313
+ else { Gm = uk; Pm = c; }
314
+ }
315
+ // row_ms_rec on the closed form: u in place of g (muscle_path_units'), the entries' codes in place of their masks; the moving sites form path_grad's
316
+ // g_j from u in its operation order, (0 + u_(j-1)) - u_j, so their terms are today's
317
+ template <int NS, int KD, int PF, class S, class T, class MV>
318
+ __device__ __forceinline__ int row_ms_rec_cf(const MuscleTables<T>& t, const MV& mv, const EntryRecs<T>& R, const kin::Pose<S>* pose,
319
+ const S* q, int m, const so3::Vec3<S>* p, const so3::Vec3<S>* u, int n, S* r) {
320
+ static_assert(PF == 0, "row_ms_rec_cf: the record prefetch arm is not carried over");
321
+ using V = so3::Vec3<S>;
322
+ const int nd = t.row_off[m + 1] - t.row_off[m];
323
+ JS_MUS_UNROLL
324
+ for (int k = 0; k < KD; ++k)
325
+ if (k < nd) r[k] = S(0);
326
+ int last = -1;
327
+ V Pm{S(0), S(0), S(0)}, Gm{S(0), S(0), S(0)};
328
+ const int e0 = t.jent_off[m], e1 = t.jent_off[m + 1];
329
+ for (int e = e0; e < e1; ++e) {
330
+ const ERec<T> cur = load_erec<T>(R, e);
331
+ if (cur.mask != last) { cf_sums<NS>(cur.mask, p, u, Pm, Gm); last = cur.mask; }
332
+ entry_contrib<KD>(cur, pose, q, Pm, Gm, r);
333
+ }
334
+ const int s0 = t.site_off[m];
335
+ JS_MUS_UNROLL
336
+ for (int j = 0; j < NS; ++j) {
337
+ if (j >= n) continue;
338
+ const int s = s0 + j;
339
+ if (!t.site_moving[s]) continue;
340
+ const T* c = t.site_coef + 15 * s;
341
+ const S th = q[t.site_cdof_q[s]];
342
+ S dx = S(4) * S(mv.at(kFieldMuscleSite, c + 12)), dy = S(4) * S(mv.at(kFieldMuscleSite, c + 13)),
343
+ dz = S(4) * S(mv.at(kFieldMuscleSite, c + 14));
344
+ for (int k = 3; k >= 1; --k) {
345
+ dx = dx * th + S(k) * S(mv.at(kFieldMuscleSite, c + 3 * k));
346
+ dy = dy * th + S(k) * S(mv.at(kFieldMuscleSite, c + 3 * k + 1));
347
+ dz = dz * th + S(k) * S(mv.at(kFieldMuscleSite, c + 3 * k + 2));
348
+ }
349
+ V gj{S(0), S(0), S(0)};
350
+ if (j > 0) gj = so3::add(gj, u[j - 1]);
351
+ if (j < NS - 1 && j < n - 1) gj = so3::sub(gj, u[j]);
352
+ const V slide = so3::quat_rotate(pose[t.site_body[s]].q, V{dx, dy, dz});
353
+ rsink_add<KD>(r, t.site_slot[s], so3::dot(gj, slide));
354
+ }
355
+ return nd;
356
+ }
357
+ #define KMUS_PATHG muscle_path_units
358
+ #define KMUS_ROW row_ms_rec_cf
359
+ #else
360
+ #define KMUS_PATHG muscle_path_grad
361
+ #define KMUS_ROW row_ms_rec
362
+ #endif
363
+
364
+ // The 14x tape (the core/soft/tape.h, feat/d16-14x afde993c; KMUS_TAPE_PREREG.md), a compile-time policy so the record-off
365
+ // kernel is unchanged: NoMusTape (k_mus), MusTapeSub (substeps 1..): this world's substep record gets lce_prev in its MUS block,
366
+ // MusTapeSub0 (substep 0): also the control record's a_0 and u. No runtime null test (the WARPSYNC-stub lesson).
367
+ struct NoMusTape {};
368
+ template <class T> struct MusTapeSub { T* rec; long long stride; js::soft::TapeLayout TL; };
369
+ template <class T> struct MusTapeSub0 { T* rec; long long stride; js::soft::TapeLayout TL; T* ctl; long long ctl_stride; };
370
+
371
+ // k_mus's body: per world, (q, lce_prev, a_prev, u) -> (tau [NV], lce_new, a_new [NM], optionally F [NM]). World-major arrays.
372
+ template <class T, int NS, int KD, int NSLOT, int NQ, int NV, int NM, class KMUS_P(Tp)>
373
+ __device__ __forceinline__ void k_mus_body(MuscleTables<T> t, MusSlots<T> sl, const T* __restrict__ q_g, // by value, as the kernel had them
374
+ const T* __restrict__ lce_g, const T* __restrict__ a_g, const T* __restrict__ u_g, T dt,
375
+ int niter, T* __restrict__ tau_g, T* __restrict__ lce_o, T* __restrict__ a_o,
376
+ T* __restrict__ F_o, Tp tp) {
377
+ const int w = blockIdx.x, lane = threadIdx.x;
378
+ // The tape (the layout: the MUS block [TL.mus, TL.words) = lce_prev [NM] then zero words; the control record [CL.words] =
379
+ // a_0 [NM], u [NM], zero words). The per-muscle words are written in the main loop below from the values it loads anyway
380
+ // (no re-read, the stores spread over the kernel: T3 measured the up-front tape_pack_range at +20 / +60 us per launch);
381
+ // here only the padding words. The words equal tape_pack_range's / tape_ctl_pack's (T1 checks it bitwise).
382
+ if constexpr (!std::is_same_v<Tp, NoMusTape>) {
383
+ T* rec = tp.rec + static_cast<long long>(w) * tp.stride;
384
+ for (int k = NM + lane; k < tp.TL.words - tp.TL.mus; k += 32) js::soft::tape_put_u(rec, tp.TL.mus + k, 0u);
385
+ if constexpr (std::is_same_v<Tp, MusTapeSub0<T>>) {
386
+ constexpr js::soft::TapeCtlLayout CL = js::soft::tape_ctl_layout(NM);
387
+ T* ctl = tp.ctl + static_cast<long long>(w) * tp.ctl_stride;
388
+ for (int k = 2 * NM + lane; k < CL.words; k += 32) js::soft::tape_put_u(ctl, k, 0u);
389
+ }
390
+ }
391
+ __shared__ T q[NQ];
392
+ __shared__ kin::Pose<T> pose[NSLOT];
393
+ __shared__ T stage[32 * KD];
394
+ __shared__ T rsh[kShRow ? 32 * KD : 1]; // arm R1's per-lane rows
395
+ F_PROF_DECL;
396
+ F_PROF_MARK(0);
397
+ for (int i = lane; i < NQ; i += 32) q[i] = q_g[static_cast<long>(w) * NQ + i];
398
+ __syncwarp();
399
+ F_PROF_MARK(1);
400
+ mus_rel_fk<T>(sl, q, pose, lane);
401
+ F_PROF_MARK(2);
402
+ ModelView<MVShared> mv(w);
403
+ constexpr int NVL = (NV + 31) / 32;
404
+ T acc[NVL];
405
+ for (int j = 0; j < NVL; ++j) acc[j] = KMUS_ACC0(lane + 32 * j < NV ? tau_g[static_cast<long>(w) * NV + lane + 32 * j] : T(0));
406
+ for (int r = 0; r * 32 < KMUS_NMC; ++r) {
407
+ // KMUS_SEG_BEGIN k_mus_round (mw/body_pair_check.py: token-identical in k_mus_body_w2)
408
+ const int mi = r * 32 + lane;
409
+ const int m = mi < KMUS_NMC ? sl.perm[mi] : NM;
410
+ if (mi < KMUS_NMC) {
411
+ const long im = static_cast<long>(w) * NM + m;
412
+ MuscleLaneOut<T, NS, KD> L; // muscle_lane_p's pieces; the row reads the entry records (fix 5 (i))
413
+ const EntryRecs<T> R{sl.erec_i, sl.erec_f};
414
+ L.a = muscle_activation<T>(t, mv, m, u_g[im], a_g[im], dt); F_PROF_MARK(3);
415
+ L.l = muscle_path<NS, T>(t, mv, pose, q, m, L.p, L.n); F_PROF_MARK(4);
416
+ KMUS_PATHG<NS, T>(L.p, L.n, L.g); F_PROF_MARK(5);
417
+ if constexpr (kShRow) {
418
+ L.nd = KMUS_ROW<NS, KD, 0, T, T>(t, mv, R, pose, q, m, L.p, L.g, L.n, rsh + lane * KD);
419
+ JS_MUS_UNROLL
420
+ for (int k = 0; k < KD; ++k) L.r[k] = rsh[lane * KD + k];
421
+ } else {
422
+ L.nd = KMUS_ROW<NS, KD, 0, T, T>(t, mv, R, pose, q, m, L.p, L.g, L.n, L.r);
423
+ }
424
+ F_PROF_MARK(6);
425
+ #ifdef D16_X14_MILLARD
426
+ const MillardPar<T> gp = millard_par<T>(t, mv, m); F_PROF_MARK(7);
427
+ L.lce = millard_fiber<T>(t, L.l, lce_g[im], L.a, dt, gp, niter, T(0), &L.F, &L.iters); F_PROF_MARK(8);
428
+ #else
429
+ const GeyerPar<T> gp = muscle_par<T>(t, mv, m); F_PROF_MARK(7);
430
+ L.lce = muscle_fiber_h<T>(L.l, lce_g[im], L.a, dt, gp, niter, T(0), &L.F, &L.iters); F_PROF_MARK(8);
431
+ #endif
432
+ if constexpr (!std::is_same_v<Tp, NoMusTape>) { // this muscle's tape words, from the loads above
433
+ js::soft::tape_st(tp.rec + static_cast<long long>(w) * tp.stride + tp.TL.mus + m, lce_g[im]);
434
+ if constexpr (std::is_same_v<Tp, MusTapeSub0<T>>) {
435
+ T* ctl = tp.ctl + static_cast<long long>(w) * tp.ctl_stride;
436
+ js::soft::tape_st(ctl + m, a_g[im]);
437
+ js::soft::tape_st(ctl + NM + m, u_g[im]);
438
+ }
439
+ }
440
+ lce_o[im] = L.lce; a_o[im] = L.a;
441
+ if (F_o) F_o[im] = L.F;
442
+ JS_MUS_UNROLL
443
+ for (int k = 0; k < KD; ++k)
444
+ if (k < L.nd) stage[lane * KD + k] = L.F * L.r[k];
445
+ F_PROF_MARK(9);
446
+ }
447
+ __syncwarp();
448
+ F_PROF_MARK(10);
449
+ for (int j = 0; j < NVL; ++j) {
450
+ const int d = lane + 32 * j;
451
+ if (d < NV) {
452
+ const int gi = r * NV + d;
453
+ for (int e = sl.g_off[gi]; e < sl.g_off[gi + 1]; ++e) acc[j] = acc[j] - stage[sl.g_ent[e]];
454
+ }
455
+ }
456
+ F_PROF_MARK(11);
457
+ __syncwarp();
458
+ // KMUS_SEG_END k_mus_round
459
+ }
460
+ for (int j = 0; j < NVL; ++j) {
461
+ const int d = lane + 32 * j;
462
+ if (d < NV) tau_g[static_cast<long>(w) * NV + d] = acc[j];
463
+ }
464
+ F_PROF_STORE;
465
+ }
466
+
467
+ // k_mus: the record-off kernel, its signature and name unchanged (its SASS is gated identical to 981c61f9's, KMUS_TAPE_PREREG T2)
468
+ template <class T, int NS, int KD, int NSLOT, int NQ, int NV, int KMUS_P(NM)>
469
+ __global__ void __launch_bounds__(32) k_mus(MuscleTables<T> t, MusSlots<T> sl, const T* __restrict__ q_g, const T* __restrict__ lce_g,
470
+ const T* __restrict__ a_g, const T* __restrict__ u_g, T dt, int niter,
471
+ T* __restrict__ tau_g, T* __restrict__ lce_o, T* __restrict__ a_o, T* __restrict__ F_o) {
472
+ k_mus_body<T, NS, KD, NSLOT, NQ, NV, NM, KMUS_A(NoMusTape)>(t, sl, q_g, lce_g, a_g, u_g, dt, niter, tau_g, lce_o, a_o, F_o, NoMusTape{});
473
+ }
474
+
475
+ // k_mus_taped: the same substep with the tape written (Tp = MusTapeSub<T> or MusTapeSub0<T>)
476
+ template <class T, int NS, int KD, int NSLOT, int NQ, int NV, int NM, class KMUS_P(Tp)>
477
+ __global__ void __launch_bounds__(32) k_mus_taped(MuscleTables<T> t, MusSlots<T> sl, const T* __restrict__ q_g,
478
+ const T* __restrict__ lce_g, const T* __restrict__ a_g, const T* __restrict__ u_g, T dt,
479
+ int niter, T* __restrict__ tau_g, T* __restrict__ lce_o, T* __restrict__ a_o,
480
+ T* __restrict__ F_o, Tp tp) {
481
+ static_assert(std::is_same_v<Tp, MusTapeSub<T>> || std::is_same_v<Tp, MusTapeSub0<T>>, "k_mus_taped: the tape policy");
482
+ k_mus_body<T, NS, KD, NSLOT, NQ, NV, NM, KMUS_A(Tp)>(t, sl, q_g, lce_g, a_g, u_g, dt, niter, tau_g, lce_o, a_o, F_o, tp);
483
+ }
484
+
485
+ // muscle_adj's body: Item 3's stage_vjp, with the geometry walked once (fix 3,
486
+ // ITEM4_FIX3_PREREG.md): FK, path, path_grad and row in Dual<T, 1> seeded along tau_bar, whose value channel is the primal
487
+ // (l, r) and whose derivative channel is J_r tau_bar (the Hessian-vector product). Then the fibre's IFT, the activation's
488
+ // VJP and the ball term tau_bar x r. q_bar's three contributions per row slot are staged apart and applied in the CPU order.
489
+ // muscle_adj's inputs, a policy (the 14x tape, the step 4): AdjSrcContig reads the world-major arrays (the item-4 kernel);
490
+ // AdjSrcTape reads q_k and lce_k from the substep record, lce_{k+1} from (ptr, stride), recomputes a_k from the control
491
+ // step's a_0 and u by k activation steps (muscle_activation, as k_mus: KMUS_TAPE_PREREG T1 shows it bitwise), and accumulates
492
+ // u_bar (one writer per element; the substeps run in a fixed order, so no atomics).
493
+ template <class T, int NQ, int NM> struct AdjSrcContig {
494
+ const T* q_g; const T* lce_g; const T* a_g; const T* u_g; const T* lnew_g; T* ub_o;
495
+ __device__ __forceinline__ T q(int w, int i) const { return q_g[static_cast<long>(w) * NQ + i]; }
496
+ __device__ __forceinline__ T lce(long im) const { return lce_g[im]; }
497
+ __device__ __forceinline__ T u(long im) const { return u_g[im]; }
498
+ __device__ __forceinline__ T lnew(long im) const { return lnew_g[im]; }
499
+ template <class MV> __device__ __forceinline__ T a(const MuscleTables<T>&, const MV&, int, long im, T, T) const { return a_g[im]; }
500
+ __device__ __forceinline__ void ub_out(long im, T v) const { ub_o[im] = v; }
501
+ };
502
+ // The ball term's entries per muscle (the lever 1, tools/d16_14x/LEVERS_BALL_PREREG.md): muscle m's joint entries on a ball, in
503
+ // entry order, as (jent_slot[e], vadr[jent_body[e]]) pairs: off [NM + 1], sv [2 off[NM]] (k_mus_host.cuh mus_ball_list builds
504
+ // them). muscle_adj's ball loop walks these instead of every entry with its two dependent table loads; the same entries in the
505
+ // same order and the same arithmetic, so its outputs are unchanged bitwise. Only the adjoint kernels take it, so k_mus's
506
+ // parameters (and SASS) are unchanged.
507
+ struct MusBall {
508
+ const int* off = nullptr;
509
+ const int* sv = nullptr;
510
+ };
511
+ template <class T> struct AdjTape {
512
+ const T* rec; long long rs; int qoff, mus; // substep k's records [n][rs]: q_k at qoff, lce_k at mus
513
+ const T* lnew; long long lns; // lce_{k+1}: the next record's MUS (+ mus) or the step's output lce (stride NM)
514
+ const T* a0; long long a0s; // the control step's a_0 [n][a0s] and u [n][us]
515
+ const T* u; long long us;
516
+ int k; // the substep: a_k = k activation steps from a_0
517
+ T* ub; long long ubs; // u_bar [n][ubs], accumulated (+=)
518
+ };
519
+ template <class T, int NQ, int NM> struct AdjSrcTape {
520
+ AdjTape<T> p;
521
+ __device__ __forceinline__ T q(int w, int i) const { return p.rec[static_cast<long long>(w) * p.rs + p.qoff + i]; }
522
+ __device__ __forceinline__ T lce(long im) const {
523
+ return p.rec[(im / NM) * p.rs + p.mus + im % NM];
524
+ }
525
+ __device__ __forceinline__ T u(long im) const { return p.u[(im / NM) * p.us + im % NM]; }
526
+ __device__ __forceinline__ T lnew(long im) const { return p.lnew[(im / NM) * p.lns + im % NM]; }
527
+ template <class MV>
528
+ __device__ __forceinline__ T a(const MuscleTables<T>& t, const MV& mv, int m, long im, T u, T dt) const {
529
+ T a = p.a0[(im / NM) * p.a0s + im % NM];
530
+ for (int j = 0; j < p.k; ++j) a = muscle_activation<T>(t, mv, m, u, a, dt);
531
+ return a;
532
+ }
533
+ __device__ __forceinline__ void ub_out(long im, T v) const {
534
+ T* d = p.ub + (im / NM) * p.ubs + im % NM;
535
+ *d = *d + v;
536
+ }
537
+ };
538
+
539
+ template <class T, int NS, int KD, int NSLOT, int NQ, int NV, int KMUS_P(NM), class Src>
540
+ __device__ __forceinline__ void muscle_adj_body(MuscleTables<T> t, MusSlots<T> sl, Src src, T dt, const T* __restrict__ tb_g,
541
+ const T* __restrict__ lb_g, const T* __restrict__ ab_g, T* __restrict__ qb_o,
542
+ T* __restrict__ lpb_o, T* __restrict__ apb_o, MusBall bl) {
543
+ using SD = diff::Dual<T, 1>;
544
+ const int w = blockIdx.x, lane = threadIdx.x;
545
+ __shared__ T q[NQ], tb[NV];
546
+ __shared__ SD qd[NQ];
547
+ __shared__ kin::Pose<SD> posed[NSLOT];
548
+ __shared__ T st_l[32 * KD], st_h[32 * KD], st_b[32 * KD];
549
+ __shared__ SD rdsh[kShRow ? 32 * KD : 1]; // arm R1's per-lane Dual rows
550
+ F_PROF_DECL;
551
+ F_PROF_MARK(0);
552
+ for (int i = lane; i < NQ; i += 32) { q[i] = src.q(w, i); qd[i] = SD(q[i]); }
553
+ for (int i = lane; i < NV; i += 32) tb[i] = tb_g[static_cast<long>(w) * NV + i];
554
+ __syncwarp();
555
+ // KMUS_SEG_BEGIN adj_seed (mw/body_pair_check.py: token-identical in muscle_adj_body_w2)
556
+ for (int j = lane; j < sl.nseed; j += 32) { // the tangent along tau_bar in today's chart (the CPU's seed_q)
557
+ const kin::JointType jt = static_cast<kin::JointType>(sl.seed[3 * j]);
558
+ const int qa = sl.seed[3 * j + 1], va = sl.seed[3 * j + 2];
559
+ if (jt == kin::JointType::Revolute || jt == kin::JointType::Slide) { qd[qa].d[0] = tb[va]; continue; }
560
+ const int qo = jt == kin::JointType::Free ? qa + 3 : qa;
561
+ const so3::Quat<T> qq{q[qo], q[qo + 1], q[qo + 2], q[qo + 3]};
562
+ const so3::Quat<T> dq = so3::quat_mul(qq, so3::Quat<T>{T(0), T(0.5) * tb[va], T(0.5) * tb[va + 1], T(0.5) * tb[va + 2]});
563
+ qd[qo].d[0] = dq.w; qd[qo + 1].d[0] = dq.x; qd[qo + 2].d[0] = dq.y; qd[qo + 3].d[0] = dq.z;
564
+ if (jt == kin::JointType::Free) {
565
+ const so3::Vec3<T> vw = so3::quat_rotate(so3::quat_normalize(qq), so3::Vec3<T>{tb[va + 3], tb[va + 4], tb[va + 5]});
566
+ qd[qa].d[0] = vw.x; qd[qa + 1].d[0] = vw.y; qd[qa + 2].d[0] = vw.z;
567
+ }
568
+ }
569
+ // KMUS_SEG_END adj_seed
570
+ __syncwarp();
571
+ F_PROF_MARK(1);
572
+ F_PROF_MARK(2); // (fix 3: no separate primal FK)
573
+ mus_rel_fk<SD>(sl, qd, posed, lane);
574
+ F_PROF_MARK(3);
575
+ ModelView<MVShared> mv(w);
576
+ constexpr int NVL = (NV + 31) / 32;
577
+ T acc[NVL];
578
+ for (int j = 0; j < NVL; ++j) acc[j] = KMUS_ACC0(lane + 32 * j < NV ? qb_o[static_cast<long>(w) * NV + lane + 32 * j] : T(0));
579
+ for (int r = 0; r * 32 < KMUS_NMC; ++r) {
580
+ // KMUS_SEG_BEGIN adj_round (mw/body_pair_check.py: token-identical in muscle_adj_body_w2)
581
+ const int mi = r * 32 + lane;
582
+ const int m = mi < KMUS_NMC ? sl.perm[mi] : NM;
583
+ for (int k = 0; k < KD; ++k) { st_l[lane * KD + k] = T(0); st_h[lane * KD + k] = T(0); st_b[lane * KD + k] = T(0); }
584
+ if (mi < KMUS_NMC) {
585
+ const long im = static_cast<long>(w) * NM + m;
586
+ const T lp = src.lce(im), u = src.u(im), lnew = src.lnew(im);
587
+ const T ap = src.a(t, mv, m, im, u, dt);
588
+ const T A = muscle_activation<T>(t, mv, m, u, ap, dt);
589
+ F_PROF_MARK(4);
590
+ so3::Vec3<SD> pd[NS], gd[NS]; int n = 0; // one walk: the value channel is the primal, d[0] the tangent
591
+ const SD ld = muscle_path<NS, SD>(t, mv, posed, qd, m, pd, n);
592
+ KMUS_PATHG<NS, SD>(pd, n, gd);
593
+ SD rd[KD];
594
+ int nd;
595
+ if constexpr (kShRow) {
596
+ nd = KMUS_ROW<NS, KD, 0, SD, T>(t, mv, EntryRecs<T>{sl.erec_i, sl.erec_f}, posed, qd, m, pd, gd, n, rdsh + lane * KD);
597
+ JS_MUS_UNROLL
598
+ for (int k = 0; k < KD; ++k) rd[k] = rdsh[lane * KD + k];
599
+ } else {
600
+ nd = KMUS_ROW<NS, KD, 0, SD, T>(t, mv, EntryRecs<T>{sl.erec_i, sl.erec_f}, posed, qd, m, pd, gd, n, rd);
601
+ }
602
+ const T l = ld.v;
603
+ T rr[KD];
604
+ JS_MUS_UNROLL
605
+ for (int k = 0; k < KD; ++k) rr[k] = k < nd ? rd[k].v : T(0);
606
+ F_PROF_MARK(5);
607
+ #ifdef D16_X14_MILLARD
608
+ const MillardPar<T> gp = millard_par<T>(t, mv, m);
609
+ const T F = millard_force<T>(t, l, lnew, lp, A, dt, gp); // the forward's F from (l, lce_new); rigid: the closed form
610
+ #else
611
+ const GeyerPar<T> gp = muscle_par<T>(t, mv, m);
612
+ T F;
613
+ if (gp.rigid) (void)geyer_rigid<T>(l, lp, A, dt, gp, &F);
614
+ else F = geyer_force_h<T>(l, lnew, gp, geyer_inv<T>(gp, dt));
615
+ #endif
616
+ const int r0 = t.row_off[m];
617
+ T F_bar = T(0);
618
+ JS_MUS_UNROLL
619
+ for (int k = 0; k < KD; ++k)
620
+ if (k < nd) F_bar = F_bar - rr[k] * tb[t.row_dof[r0 + k]];
621
+ T l_bar = T(0), lpb = T(0), A_bar = T(0);
622
+ #ifdef D16_X14_MILLARD
623
+ millard_fiber_vjp<T>(t, lnew, l, lp, A, dt, gp, F_bar, lb_g[im], l_bar, lpb, A_bar);
624
+ #else
625
+ muscle_fiber_vjp_h<T>(lnew, l, lp, A, dt, gp, F_bar, lb_g[im], l_bar, lpb, A_bar);
626
+ #endif
627
+ T ub = T(0), apb = T(0);
628
+ muscle_activation_vjp<T>(t, mv, m, u, ap, dt, A_bar + ab_g[im], ub, apb);
629
+ lpb_o[im] = lpb; apb_o[im] = apb; src.ub_out(im, ub);
630
+ #ifdef F_KMUS_PROF
631
+ if (g_adj_F) static_cast<T*>(g_adj_F)[im] = F;
632
+ #endif
633
+ F_PROF_MARK(6);
634
+ JS_MUS_UNROLL
635
+ for (int k = 0; k < KD; ++k)
636
+ if (k < nd) { st_l[lane * KD + k] = l_bar * rr[k]; st_h[lane * KD + k] = F * rd[k].d[0]; }
637
+ F_PROF_MARK(7);
638
+ for (int k = bl.off[m]; k < bl.off[m + 1]; ++k) { // the ball term -F (tau_bar x r) on each ball's 3 dofs (MusBall's list)
639
+ const int s0 = bl.sv[2 * k], va = bl.sv[2 * k + 1];
640
+ const so3::Vec3<T> c = so3::cross(so3::Vec3<T>{tb[va], tb[va + 1], tb[va + 2]},
641
+ so3::Vec3<T>{row_get<KD>(rr, s0), row_get<KD>(rr, s0 + 1), row_get<KD>(rr, s0 + 2)});
642
+ st_b[lane * KD + s0] = F * c.x; st_b[lane * KD + s0 + 1] = F * c.y; st_b[lane * KD + s0 + 2] = F * c.z;
643
+ }
644
+ F_PROF_MARK(8);
645
+ }
646
+ __syncwarp();
647
+ F_PROF_MARK(9);
648
+ for (int j = 0; j < NVL; ++j) { // q_bar in the CPU's order: per muscle (one slot per dof), + l_bar r, - F J_r tau_bar, - ball
649
+ const int d = lane + 32 * j;
650
+ if (d < NV) {
651
+ const int gi = r * NV + d;
652
+ for (int e = sl.g_off[gi]; e < sl.g_off[gi + 1]; ++e) {
653
+ const int x = sl.g_ent[e];
654
+ acc[j] = acc[j] + st_l[x]; acc[j] = acc[j] - st_h[x]; acc[j] = acc[j] - st_b[x];
655
+ }
656
+ }
657
+ }
658
+ F_PROF_MARK(10);
659
+ __syncwarp();
660
+ // KMUS_SEG_END adj_round
661
+ }
662
+ for (int j = 0; j < NVL; ++j) {
663
+ const int d = lane + 32 * j;
664
+ if (d < NV) qb_o[static_cast<long>(w) * NV + d] = acc[j];
665
+ }
666
+ F_PROF_MARK(11);
667
+ F_PROF_STORE;
668
+ }
669
+
670
+ // muscle_adj: per world, (q, lce_prev, a_prev, u, lce_new; tau_bar [NV], lce_bar, a_bar [NM]) ->
671
+ // (q_bar [NV], lce_prev_bar, a_prev_bar, u_bar [NM]), world-major arrays (the item-4 kernel; MusBall appended by lever 1)
672
+ template <class T, int NS, int KD, int NSLOT, int NQ, int NV, int KMUS_P(NM)>
673
+ __global__ void __launch_bounds__(32) muscle_adj(MuscleTables<T> t, MusSlots<T> sl, const T* __restrict__ q_g, const T* __restrict__ lce_g,
674
+ const T* __restrict__ a_g, const T* __restrict__ u_g, const T* __restrict__ lnew_g, T dt,
675
+ const T* __restrict__ tb_g, const T* __restrict__ lb_g, const T* __restrict__ ab_g,
676
+ T* __restrict__ qb_o, T* __restrict__ lpb_o, T* __restrict__ apb_o, T* __restrict__ ub_o,
677
+ MusBall bl) {
678
+ muscle_adj_body<T, NS, KD, NSLOT, NQ, NV, KMUS_A(NM)>(t, sl, AdjSrcContig<T, NQ, NM>{q_g, lce_g, a_g, u_g, lnew_g, ub_o}, dt, tb_g, lb_g, ab_g,
679
+ qb_o, lpb_o, apb_o, bl);
680
+ }
681
+
682
+ // muscle_adj_taped: one substep k of the 14x control step's reverse (the step 4) from the tape: tau_bar_k [n][NV] (from the
683
+ // rigid adjoint), lce_{k+1}_bar and a_{k+1}_bar [n][NM] in; qmus_k [n][NV] (law14's chart: the root entries are 0, balls the
684
+ // body-frame Exp(delta / 2) increment, hinges and masters additive), lce_k_bar and a_k_bar [n][NM] out; u_bar accumulated.
685
+ // The caller runs k = 4..0, zeroes u_bar first and chains lce_k_bar / a_k_bar into substep k - 1.
686
+ template <class T, int NS, int KD, int NSLOT, int NQ, int NV, int KMUS_P(NM)>
687
+ __global__ void __launch_bounds__(32) muscle_adj_taped(MuscleTables<T> t, MusSlots<T> sl, AdjTape<T> tp, T dt, const T* __restrict__ tb_g,
688
+ const T* __restrict__ lb_g, const T* __restrict__ ab_g, T* __restrict__ qb_o,
689
+ T* __restrict__ lpb_o, T* __restrict__ apb_o, MusBall bl) {
690
+ muscle_adj_body<T, NS, KD, NSLOT, NQ, NV, KMUS_A(NM)>(t, sl, AdjSrcTape<T, NQ, NM>{tp}, dt, tb_g, lb_g, ab_g, qb_o, lpb_o, apb_o, bl);
691
+ }
692
+
693
+ #if defined(D16_BODY_MUS_W2)
694
+ // ---- The narrow muscle class at two warps per world (2026-11-08; tools/d16_bodies/mw/PREREG_MW2.md, the review MW2_REVIEW.md) ----
695
+ // k_mus_body / muscle_adj_body run by 64 threads: warp 0 alone loads q and runs the slot FK (and the adjoint's seed and Dual FK), one __syncthreads, then
696
+ // warp k runs the rounds of pair p as r = 2p + (k ^ (p & 1)) (a snake: 0, 3, 4, 7, 8, 11 / 1, 2, 5, 6, 9, 10) with its own stage arrays and acc, and at
697
+ // the end warp 1 hands its acc to warp 0 through red[NV] (tau or q_bar = warp 0's sum + warp 1's: a new summation order, a tolerance gate). The
698
+ // marked segments are today's text, token for token (mw/body_pair_check.py, the A1); the per-warp stage arrays are reached by today's names.
699
+ // Tape padding from warp 0 only (the A2); a two-warp profile indexes its buffer by 64 threads (F_PROF_STORE64, the host's [n][64][marks]).
700
+ #ifdef F_KMUS_PROF
701
+ #define F_PROF_STORE64 do { if (g_mus_prof) { _Pragma("unroll") for (int f_i = 0; f_i < kProfMarks; ++f_i) \
702
+ g_mus_prof[(static_cast<long>(blockIdx.x) * 64 + threadIdx.x) * kProfMarks + f_i] = f_prof_acc[f_i]; } } while (0)
703
+ #else
704
+ #define F_PROF_STORE64 do {} while (0)
705
+ #endif
706
+ #ifndef KMUS_W2_PLANT
707
+ #define KMUS_W2_PLANT 0 // 1 (gate builds only): warp 1's sum is dropped from the reduction, which kmus_gate's G1 must catch
708
+ #endif
709
+
710
+ template <class T, int NS, int KD, int NSLOT, int NQ, int NV, int NM, class Tp, int NMC, bool ACC_IN>
711
+ __device__ __forceinline__ void k_mus_body_w2(MuscleTables<T> t, MusSlots<T> sl, const T* __restrict__ q_g, const T* __restrict__ lce_g,
712
+ const T* __restrict__ a_g, const T* __restrict__ u_g, T dt, int niter, T* __restrict__ tau_g,
713
+ T* __restrict__ lce_o, T* __restrict__ a_o, T* __restrict__ F_o, Tp tp) {
714
+ static_assert(!ACC_IN, "k_mus_body_w2: the narrow class, which starts its sum at 0");
715
+ const int w = blockIdx.x, lane = threadIdx.x & 31, warp = threadIdx.x >> 5;
716
+ if constexpr (!std::is_same_v<Tp, NoMusTape>) { // the tape's padding words (k_mus_body's), warp 0 only
717
+ if (warp == 0) {
718
+ T* rec = tp.rec + static_cast<long long>(w) * tp.stride;
719
+ for (int k = NM + lane; k < tp.TL.words - tp.TL.mus; k += 32) js::soft::tape_put_u(rec, tp.TL.mus + k, 0u);
720
+ if constexpr (std::is_same_v<Tp, MusTapeSub0<T>>) {
721
+ constexpr js::soft::TapeCtlLayout CL = js::soft::tape_ctl_layout(NM);
722
+ T* ctl = tp.ctl + static_cast<long long>(w) * tp.ctl_stride;
723
+ for (int k = 2 * NM + lane; k < CL.words; k += 32) js::soft::tape_put_u(ctl, k, 0u);
724
+ }
725
+ }
726
+ }
727
+ __shared__ T q[NQ];
728
+ __shared__ kin::Pose<T> pose[NSLOT];
729
+ __shared__ T stage_w[2][32 * KD];
730
+ __shared__ T rsh_w[kShRow ? 2 : 1][kShRow ? 32 * KD : 1];
731
+ __shared__ T red[NV];
732
+ T* const stage = stage_w[warp];
733
+ T* const rsh = rsh_w[kShRow ? warp : 0];
734
+ F_PROF_DECL;
735
+ F_PROF_MARK(0);
736
+ if (warp == 0) {
737
+ for (int i = lane; i < NQ; i += 32) q[i] = q_g[static_cast<long>(w) * NQ + i];
738
+ __syncwarp();
739
+ F_PROF_MARK(1);
740
+ mus_rel_fk<T>(sl, q, pose, lane);
741
+ }
742
+ __syncthreads();
743
+ F_PROF_MARK(2);
744
+ ModelView<MVShared> mv(w);
745
+ constexpr int NVL = (NV + 31) / 32;
746
+ T acc[NVL];
747
+ for (int j = 0; j < NVL; ++j) acc[j] = KMUS_ACC0(lane + 32 * j < NV ? tau_g[static_cast<long>(w) * NV + lane + 32 * j] : T(0));
748
+ for (int rp = 0; 2 * rp * 32 < KMUS_NMC; ++rp) {
749
+ const int r = 2 * rp + (warp ^ (rp & 1));
750
+ if (r * 32 >= KMUS_NMC) break;
751
+ // KMUS_SEG_BEGIN k_mus_round (a copy: mw/body_pair_check.py)
752
+ const int mi = r * 32 + lane;
753
+ const int m = mi < KMUS_NMC ? sl.perm[mi] : NM;
754
+ if (mi < KMUS_NMC) {
755
+ const long im = static_cast<long>(w) * NM + m;
756
+ MuscleLaneOut<T, NS, KD> L; // muscle_lane_p's pieces; the row reads the entry records (fix 5 (i))
757
+ const EntryRecs<T> R{sl.erec_i, sl.erec_f};
758
+ L.a = muscle_activation<T>(t, mv, m, u_g[im], a_g[im], dt); F_PROF_MARK(3);
759
+ L.l = muscle_path<NS, T>(t, mv, pose, q, m, L.p, L.n); F_PROF_MARK(4);
760
+ KMUS_PATHG<NS, T>(L.p, L.n, L.g); F_PROF_MARK(5);
761
+ if constexpr (kShRow) {
762
+ L.nd = KMUS_ROW<NS, KD, 0, T, T>(t, mv, R, pose, q, m, L.p, L.g, L.n, rsh + lane * KD);
763
+ JS_MUS_UNROLL
764
+ for (int k = 0; k < KD; ++k) L.r[k] = rsh[lane * KD + k];
765
+ } else {
766
+ L.nd = KMUS_ROW<NS, KD, 0, T, T>(t, mv, R, pose, q, m, L.p, L.g, L.n, L.r);
767
+ }
768
+ F_PROF_MARK(6);
769
+ #ifdef D16_X14_MILLARD
770
+ const MillardPar<T> gp = millard_par<T>(t, mv, m); F_PROF_MARK(7);
771
+ L.lce = millard_fiber<T>(t, L.l, lce_g[im], L.a, dt, gp, niter, T(0), &L.F, &L.iters); F_PROF_MARK(8);
772
+ #else
773
+ const GeyerPar<T> gp = muscle_par<T>(t, mv, m); F_PROF_MARK(7);
774
+ L.lce = muscle_fiber_h<T>(L.l, lce_g[im], L.a, dt, gp, niter, T(0), &L.F, &L.iters); F_PROF_MARK(8);
775
+ #endif
776
+ if constexpr (!std::is_same_v<Tp, NoMusTape>) { // this muscle's tape words, from the loads above
777
+ js::soft::tape_st(tp.rec + static_cast<long long>(w) * tp.stride + tp.TL.mus + m, lce_g[im]);
778
+ if constexpr (std::is_same_v<Tp, MusTapeSub0<T>>) {
779
+ T* ctl = tp.ctl + static_cast<long long>(w) * tp.ctl_stride;
780
+ js::soft::tape_st(ctl + m, a_g[im]);
781
+ js::soft::tape_st(ctl + NM + m, u_g[im]);
782
+ }
783
+ }
784
+ lce_o[im] = L.lce; a_o[im] = L.a;
785
+ if (F_o) F_o[im] = L.F;
786
+ JS_MUS_UNROLL
787
+ for (int k = 0; k < KD; ++k)
788
+ if (k < L.nd) stage[lane * KD + k] = L.F * L.r[k];
789
+ F_PROF_MARK(9);
790
+ }
791
+ __syncwarp();
792
+ F_PROF_MARK(10);
793
+ for (int j = 0; j < NVL; ++j) {
794
+ const int d = lane + 32 * j;
795
+ if (d < NV) {
796
+ const int gi = r * NV + d;
797
+ for (int e = sl.g_off[gi]; e < sl.g_off[gi + 1]; ++e) acc[j] = acc[j] - stage[sl.g_ent[e]];
798
+ }
799
+ }
800
+ F_PROF_MARK(11);
801
+ __syncwarp();
802
+ // KMUS_SEG_END k_mus_round
803
+ }
804
+ if (warp == 1)
805
+ for (int j = 0; j < NVL; ++j) {
806
+ const int d = lane + 32 * j;
807
+ if (d < NV) red[d] = KMUS_W2_PLANT == 1 ? T(0) : acc[j];
808
+ }
809
+ __syncthreads();
810
+ if (warp == 0)
811
+ for (int j = 0; j < NVL; ++j) {
812
+ const int d = lane + 32 * j;
813
+ if (d < NV) tau_g[static_cast<long>(w) * NV + d] = acc[j] + red[d];
814
+ }
815
+ F_PROF_STORE64;
816
+ }
817
+
818
+ template <class T, int NS, int KD, int NSLOT, int NQ, int NV, int NM, int NMC, bool ACC_IN, class Src>
819
+ __device__ __forceinline__ void muscle_adj_body_w2(MuscleTables<T> t, MusSlots<T> sl, Src src, T dt, const T* __restrict__ tb_g,
820
+ const T* __restrict__ lb_g, const T* __restrict__ ab_g, T* __restrict__ qb_o,
821
+ T* __restrict__ lpb_o, T* __restrict__ apb_o, MusBall bl) {
822
+ static_assert(!ACC_IN, "muscle_adj_body_w2: the narrow class, which starts its sum at 0");
823
+ using SD = diff::Dual<T, 1>;
824
+ const int w = blockIdx.x, lane = threadIdx.x & 31, warp = threadIdx.x >> 5;
825
+ __shared__ T q[NQ], tb[NV];
826
+ __shared__ SD qd[NQ];
827
+ __shared__ kin::Pose<SD> posed[NSLOT];
828
+ __shared__ T st_lw[2][32 * KD], st_hw[2][32 * KD], st_bw[2][32 * KD];
829
+ __shared__ SD rdsh_w[kShRow ? 2 : 1][kShRow ? 32 * KD : 1];
830
+ __shared__ T red[NV];
831
+ T* const st_l = st_lw[warp];
832
+ T* const st_h = st_hw[warp];
833
+ T* const st_b = st_bw[warp];
834
+ SD* const rdsh = rdsh_w[kShRow ? warp : 0];
835
+ F_PROF_DECL;
836
+ F_PROF_MARK(0);
837
+ if (warp == 0) {
838
+ for (int i = lane; i < NQ; i += 32) { q[i] = src.q(w, i); qd[i] = SD(q[i]); }
839
+ for (int i = lane; i < NV; i += 32) tb[i] = tb_g[static_cast<long>(w) * NV + i];
840
+ __syncwarp();
841
+ // KMUS_SEG_BEGIN adj_seed (a copy: mw/body_pair_check.py)
842
+ for (int j = lane; j < sl.nseed; j += 32) { // the tangent along tau_bar in today's chart (the CPU's seed_q)
843
+ const kin::JointType jt = static_cast<kin::JointType>(sl.seed[3 * j]);
844
+ const int qa = sl.seed[3 * j + 1], va = sl.seed[3 * j + 2];
845
+ if (jt == kin::JointType::Revolute || jt == kin::JointType::Slide) { qd[qa].d[0] = tb[va]; continue; }
846
+ const int qo = jt == kin::JointType::Free ? qa + 3 : qa;
847
+ const so3::Quat<T> qq{q[qo], q[qo + 1], q[qo + 2], q[qo + 3]};
848
+ const so3::Quat<T> dq = so3::quat_mul(qq, so3::Quat<T>{T(0), T(0.5) * tb[va], T(0.5) * tb[va + 1], T(0.5) * tb[va + 2]});
849
+ qd[qo].d[0] = dq.w; qd[qo + 1].d[0] = dq.x; qd[qo + 2].d[0] = dq.y; qd[qo + 3].d[0] = dq.z;
850
+ if (jt == kin::JointType::Free) {
851
+ const so3::Vec3<T> vw = so3::quat_rotate(so3::quat_normalize(qq), so3::Vec3<T>{tb[va + 3], tb[va + 4], tb[va + 5]});
852
+ qd[qa].d[0] = vw.x; qd[qa + 1].d[0] = vw.y; qd[qa + 2].d[0] = vw.z;
853
+ }
854
+ }
855
+ // KMUS_SEG_END adj_seed
856
+ __syncwarp();
857
+ F_PROF_MARK(1);
858
+ F_PROF_MARK(2); // (fix 3: no separate primal FK)
859
+ mus_rel_fk<SD>(sl, qd, posed, lane);
860
+ }
861
+ __syncthreads();
862
+ F_PROF_MARK(3);
863
+ ModelView<MVShared> mv(w);
864
+ constexpr int NVL = (NV + 31) / 32;
865
+ T acc[NVL];
866
+ for (int j = 0; j < NVL; ++j) acc[j] = KMUS_ACC0(lane + 32 * j < NV ? qb_o[static_cast<long>(w) * NV + lane + 32 * j] : T(0));
867
+ for (int rp = 0; 2 * rp * 32 < KMUS_NMC; ++rp) {
868
+ const int r = 2 * rp + (warp ^ (rp & 1));
869
+ if (r * 32 >= KMUS_NMC) break;
870
+ // KMUS_SEG_BEGIN adj_round (a copy: mw/body_pair_check.py)
871
+ const int mi = r * 32 + lane;
872
+ const int m = mi < KMUS_NMC ? sl.perm[mi] : NM;
873
+ for (int k = 0; k < KD; ++k) { st_l[lane * KD + k] = T(0); st_h[lane * KD + k] = T(0); st_b[lane * KD + k] = T(0); }
874
+ if (mi < KMUS_NMC) {
875
+ const long im = static_cast<long>(w) * NM + m;
876
+ const T lp = src.lce(im), u = src.u(im), lnew = src.lnew(im);
877
+ const T ap = src.a(t, mv, m, im, u, dt);
878
+ const T A = muscle_activation<T>(t, mv, m, u, ap, dt);
879
+ F_PROF_MARK(4);
880
+ so3::Vec3<SD> pd[NS], gd[NS]; int n = 0; // one walk: the value channel is the primal, d[0] the tangent
881
+ const SD ld = muscle_path<NS, SD>(t, mv, posed, qd, m, pd, n);
882
+ KMUS_PATHG<NS, SD>(pd, n, gd);
883
+ SD rd[KD];
884
+ int nd;
885
+ if constexpr (kShRow) {
886
+ nd = KMUS_ROW<NS, KD, 0, SD, T>(t, mv, EntryRecs<T>{sl.erec_i, sl.erec_f}, posed, qd, m, pd, gd, n, rdsh + lane * KD);
887
+ JS_MUS_UNROLL
888
+ for (int k = 0; k < KD; ++k) rd[k] = rdsh[lane * KD + k];
889
+ } else {
890
+ nd = KMUS_ROW<NS, KD, 0, SD, T>(t, mv, EntryRecs<T>{sl.erec_i, sl.erec_f}, posed, qd, m, pd, gd, n, rd);
891
+ }
892
+ const T l = ld.v;
893
+ T rr[KD];
894
+ JS_MUS_UNROLL
895
+ for (int k = 0; k < KD; ++k) rr[k] = k < nd ? rd[k].v : T(0);
896
+ F_PROF_MARK(5);
897
+ #ifdef D16_X14_MILLARD
898
+ const MillardPar<T> gp = millard_par<T>(t, mv, m);
899
+ const T F = millard_force<T>(t, l, lnew, lp, A, dt, gp); // the forward's F from (l, lce_new); rigid: the closed form
900
+ #else
901
+ const GeyerPar<T> gp = muscle_par<T>(t, mv, m);
902
+ T F;
903
+ if (gp.rigid) (void)geyer_rigid<T>(l, lp, A, dt, gp, &F);
904
+ else F = geyer_force_h<T>(l, lnew, gp, geyer_inv<T>(gp, dt));
905
+ #endif
906
+ const int r0 = t.row_off[m];
907
+ T F_bar = T(0);
908
+ JS_MUS_UNROLL
909
+ for (int k = 0; k < KD; ++k)
910
+ if (k < nd) F_bar = F_bar - rr[k] * tb[t.row_dof[r0 + k]];
911
+ T l_bar = T(0), lpb = T(0), A_bar = T(0);
912
+ #ifdef D16_X14_MILLARD
913
+ millard_fiber_vjp<T>(t, lnew, l, lp, A, dt, gp, F_bar, lb_g[im], l_bar, lpb, A_bar);
914
+ #else
915
+ muscle_fiber_vjp_h<T>(lnew, l, lp, A, dt, gp, F_bar, lb_g[im], l_bar, lpb, A_bar);
916
+ #endif
917
+ T ub = T(0), apb = T(0);
918
+ muscle_activation_vjp<T>(t, mv, m, u, ap, dt, A_bar + ab_g[im], ub, apb);
919
+ lpb_o[im] = lpb; apb_o[im] = apb; src.ub_out(im, ub);
920
+ #ifdef F_KMUS_PROF
921
+ if (g_adj_F) static_cast<T*>(g_adj_F)[im] = F;
922
+ #endif
923
+ F_PROF_MARK(6);
924
+ JS_MUS_UNROLL
925
+ for (int k = 0; k < KD; ++k)
926
+ if (k < nd) { st_l[lane * KD + k] = l_bar * rr[k]; st_h[lane * KD + k] = F * rd[k].d[0]; }
927
+ F_PROF_MARK(7);
928
+ for (int k = bl.off[m]; k < bl.off[m + 1]; ++k) { // the ball term -F (tau_bar x r) on each ball's 3 dofs (MusBall's list)
929
+ const int s0 = bl.sv[2 * k], va = bl.sv[2 * k + 1];
930
+ const so3::Vec3<T> c = so3::cross(so3::Vec3<T>{tb[va], tb[va + 1], tb[va + 2]},
931
+ so3::Vec3<T>{row_get<KD>(rr, s0), row_get<KD>(rr, s0 + 1), row_get<KD>(rr, s0 + 2)});
932
+ st_b[lane * KD + s0] = F * c.x; st_b[lane * KD + s0 + 1] = F * c.y; st_b[lane * KD + s0 + 2] = F * c.z;
933
+ }
934
+ F_PROF_MARK(8);
935
+ }
936
+ __syncwarp();
937
+ F_PROF_MARK(9);
938
+ for (int j = 0; j < NVL; ++j) { // q_bar in the CPU's order: per muscle (one slot per dof), + l_bar r, - F J_r tau_bar, - ball
939
+ const int d = lane + 32 * j;
940
+ if (d < NV) {
941
+ const int gi = r * NV + d;
942
+ for (int e = sl.g_off[gi]; e < sl.g_off[gi + 1]; ++e) {
943
+ const int x = sl.g_ent[e];
944
+ acc[j] = acc[j] + st_l[x]; acc[j] = acc[j] - st_h[x]; acc[j] = acc[j] - st_b[x];
945
+ }
946
+ }
947
+ }
948
+ F_PROF_MARK(10);
949
+ __syncwarp();
950
+ // KMUS_SEG_END adj_round
951
+ }
952
+ if (warp == 1)
953
+ for (int j = 0; j < NVL; ++j) {
954
+ const int d = lane + 32 * j;
955
+ if (d < NV) red[d] = KMUS_W2_PLANT == 1 ? T(0) : acc[j];
956
+ }
957
+ __syncthreads();
958
+ if (warp == 0)
959
+ for (int j = 0; j < NVL; ++j) {
960
+ const int d = lane + 32 * j;
961
+ if (d < NV) qb_o[static_cast<long>(w) * NV + d] = acc[j] + red[d];
962
+ }
963
+ F_PROF_MARK(11);
964
+ F_PROF_STORE64;
965
+ }
966
+
967
+ // the two-warp kernels: launched <<<n, 64>>> by k_mus_host.cuh's class launchers (the narrow class); k_mus at <= 128 registers (the A3: 16 warp slots)
968
+ template <class T, int NS, int KD, int NSLOT, int NQ, int NV, int NM, int NMC>
969
+ __global__ void __launch_bounds__(64, 8) k_mus_w2(MuscleTables<T> t, MusSlots<T> sl, const T* __restrict__ q_g, const T* __restrict__ lce_g,
970
+ const T* __restrict__ a_g, const T* __restrict__ u_g, T dt, int niter, T* __restrict__ tau_g,
971
+ T* __restrict__ lce_o, T* __restrict__ a_o, T* __restrict__ F_o) {
972
+ k_mus_body_w2<T, NS, KD, NSLOT, NQ, NV, NM, NoMusTape, NMC, false>(t, sl, q_g, lce_g, a_g, u_g, dt, niter, tau_g, lce_o, a_o, F_o, NoMusTape{});
973
+ }
974
+ template <class T, int NS, int KD, int NSLOT, int NQ, int NV, int NM, class Tp, int NMC>
975
+ __global__ void __launch_bounds__(64, 8) k_mus_taped_w2(MuscleTables<T> t, MusSlots<T> sl, const T* __restrict__ q_g, const T* __restrict__ lce_g,
976
+ const T* __restrict__ a_g, const T* __restrict__ u_g, T dt, int niter, T* __restrict__ tau_g,
977
+ T* __restrict__ lce_o, T* __restrict__ a_o, T* __restrict__ F_o, Tp tp) {
978
+ static_assert(std::is_same_v<Tp, MusTapeSub<T>> || std::is_same_v<Tp, MusTapeSub0<T>>, "k_mus_taped_w2: the tape policy");
979
+ k_mus_body_w2<T, NS, KD, NSLOT, NQ, NV, NM, Tp, NMC, false>(t, sl, q_g, lce_g, a_g, u_g, dt, niter, tau_g, lce_o, a_o, F_o, tp);
980
+ }
981
+ template <class T, int NS, int KD, int NSLOT, int NQ, int NV, int NM, int NMC>
982
+ __global__ void __launch_bounds__(64) muscle_adj_w2(MuscleTables<T> t, MusSlots<T> sl, const T* __restrict__ q_g, const T* __restrict__ lce_g,
983
+ const T* __restrict__ a_g, const T* __restrict__ u_g, const T* __restrict__ lnew_g, T dt,
984
+ const T* __restrict__ tb_g, const T* __restrict__ lb_g, const T* __restrict__ ab_g,
985
+ T* __restrict__ qb_o, T* __restrict__ lpb_o, T* __restrict__ apb_o, T* __restrict__ ub_o,
986
+ MusBall bl) {
987
+ muscle_adj_body_w2<T, NS, KD, NSLOT, NQ, NV, NM, NMC, false>(t, sl, AdjSrcContig<T, NQ, NM>{q_g, lce_g, a_g, u_g, lnew_g, ub_o}, dt, tb_g, lb_g, ab_g,
988
+ qb_o, lpb_o, apb_o, bl);
989
+ }
990
+ template <class T, int NS, int KD, int NSLOT, int NQ, int NV, int NM, int NMC>
991
+ __global__ void __launch_bounds__(64) muscle_adj_taped_w2(MuscleTables<T> t, MusSlots<T> sl, AdjTape<T> tp, T dt, const T* __restrict__ tb_g,
992
+ const T* __restrict__ lb_g, const T* __restrict__ ab_g, T* __restrict__ qb_o,
993
+ T* __restrict__ lpb_o, T* __restrict__ apb_o, MusBall bl) {
994
+ muscle_adj_body_w2<T, NS, KD, NSLOT, NQ, NV, NM, NMC, false>(t, sl, AdjSrcTape<T, NQ, NM>{tp}, dt, tb_g, lb_g, ab_g, qb_o, lpb_o, apb_o, bl);
995
+ }
996
+ #endif
997
+
998
+ // k_mus_equil (P1, tools/e0speed/CAPTURE_PLAN.md): the reset's fibre equilibrium on this law. Per world under `mask`: the
999
+ // relative FK, each muscle's path length, then `outer` rounds of the stage's own fibre solve at A = a0 with l_ce_prev <- l_ce,
1000
+ // i.e. v_ce -> 0, whose fixed point is the isometric equilibrium (the same iteration mtu_gpu.equilibrate_fibers runs on the old
1001
+ // engine's f64 coupling call). Worlds off the mask copy l_ce through, so the launch has fixed shapes and no host read.
1002
+ // World-major arrays: q [n][NQ] (the law chart), lce, a0, lce_o [n][NM]; in place (lce_o == lce) is allowed.
1003
+ template <class T, int NS, int NSLOT, int NQ, int NM>
1004
+ __global__ void __launch_bounds__(32) k_mus_equil(MuscleTables<T> t, MusSlots<T> sl, const T* __restrict__ q_g, const T* lce_g,
1005
+ const T* __restrict__ a_g, const unsigned char* __restrict__ mask, T dt, int niter,
1006
+ int outer, T* lce_o) {
1007
+ const int w = blockIdx.x, lane = threadIdx.x;
1008
+ const long base = static_cast<long>(w) * NM;
1009
+ if (!mask[w]) { // uniform across the warp (one world per block)
1010
+ for (int m = lane; m < NM; m += 32) lce_o[base + m] = lce_g[base + m];
1011
+ return;
1012
+ }
1013
+ __shared__ T q[NQ];
1014
+ __shared__ kin::Pose<T> pose[NSLOT];
1015
+ for (int i = lane; i < NQ; i += 32) q[i] = q_g[static_cast<long>(w) * NQ + i];
1016
+ __syncwarp();
1017
+ mus_rel_fk<T>(sl, q, pose, lane);
1018
+ ModelView<MVShared> mv(w);
1019
+ for (int m = lane; m < NM; m += 32) {
1020
+ so3::Vec3<T> p[NS];
1021
+ int np = 0;
1022
+ const T l = muscle_path<NS, T>(t, mv, pose, q, m, p, np);
1023
+ #ifdef D16_X14_MILLARD
1024
+ const MillardPar<T> gp = millard_par<T>(t, mv, m);
1025
+ const T A = a_g[base + m];
1026
+ T lce = lce_g[base + m], F = T(0);
1027
+ for (int k = 0; k < outer; ++k) lce = millard_fiber<T>(t, l, lce, A, dt, gp, niter, T(0), &F);
1028
+ #else
1029
+ const GeyerPar<T> gp = muscle_par<T>(t, mv, m);
1030
+ const T A = a_g[base + m];
1031
+ T lce = lce_g[base + m], F = T(0);
1032
+ for (int k = 0; k < outer; ++k) lce = muscle_fiber_h<T>(l, lce, A, dt, gp, niter, T(0), &F);
1033
+ #endif
1034
+ lce_o[base + m] = lce;
1035
+ }
1036
+ }
1037
+
1038
+ } // namespace js::soft::gpu