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,500 @@
1
+ #pragma once
2
+ // D16 14x adjoint, the tree (engine C, 2026-11-03; tools/d16_x14adj/PLAN.md "tree14"): the cotangent of
3
+ // L(q, v) = lam' (M(q) a + bias(q, v)) (RNEA at the accelerations a with gravity, the 14x's coupled tree)
4
+ // in q's tangent chart and in v, for given a (a*) and lam, as the reverse-mode transcription of kernel P's own sweeps
5
+ // (core/soft/gpu/kp14.cuh: the poses, w, al, ao by levels; each body's Newton-Euler terms), not closed-form derivative formulas.
6
+ //
7
+ // Forward (DOWN; the frames by levels on the host, from the record's POSE block on the device, and the chains as prefix sums
8
+ // (lever 1, tree14_chains); the root's parent is the world at rest, gravity as its base acceleration):
9
+ // pose (x_b, R_b), r_b = x_b - x_p = R_p pos_b, sw = R_b sl (the joint's angular velocity), swa = R_b sla, swl = R_b sll
10
+ // w_b = w_p + sw; al_b = al_p + w_p x sw + swa; ao_b = ao_p + al_p x r + w_p x (w_p x r)
11
+ // lw_b = lw_p + swl; lo_b = lo_p + lw_p x r (the twist of lam taken as joint velocities: lam's virtual power)
12
+ // root: x = q[0:3], w = sw, al = swa, ao = a[0:3] - g, lw = swl, lo = lam[0:3]
13
+ // hinge: sl = axis c qdot_m (sla, sll with a_m, lam_m); ball and root rotation: the body-frame vectors themselves.
14
+ // Then L = sum_b L_b + lam' (armature a), with each body's L_b = lw . N + (lo + lw x rc) . f, where rc = R_b ipos,
15
+ // acom = ao + al x rc + w x (w x rc), f = m acom, N = I al + w x (I w) (I the world inertia about the com).
16
+ //
17
+ // Reverse:
18
+ // LOCAL, every body: L_b's cotangents of (w, al, ao, lw, lo) and its frame's rotation cotangent from rc and I.
19
+ // UP (lever 1: the transposed prefix sums, tree14_up): each body's accumulated cotangents (its own plus its children's) reversed
20
+ // through its recursion step, which hands its parent: wbar, albar, aobar, lwbar, lobar, and the subtree's pose
21
+ // wrench W = (force, torque about O = the root origin).
22
+ // Every q dependence is a frame-attached quantity:
23
+ // - r_b, attached to the parent: a couple r x rbar on the parent;
24
+ // - the world joint vectors sw, swa, swl and rc, I, attached to the body itself: its own couple.
25
+ // A joint's tangent then receives xbar_e = S_e . W_sub(b_e), with S_e its motion about O:
26
+ // - kind 0 (root translation): e_k;
27
+ // - kind 1 (body-frame rotation: root, balls): R_b e_k through x_b;
28
+ // - kind 2 (hinge): R_b axis through x_b.
29
+ // The reduced bars are q_tan[m] += c_e xbar_e and v[m] += c_e vbar_e, summed per reduced dof in the generated (BiasOff /
30
+ // BiasE) order.
31
+ // Because body-fixed axes ride with their body and the root's translation axes are world-fixed, the balls' non-commuting
32
+ // body-frame increments, the coupling and the free root need no special case.
33
+ // Deterministic: fixed ownership (lanes over a level's bodies, over a message's words, or over the expanded dofs), fixed
34
+ // summation orders, no atomics.
35
+ #include "x14adj_common.h"
36
+ #include "scan14.h"
37
+
38
+ // X14ADJ_PLANT (default off; the gates' planted-bug builds only): 21 drops the body's own joint-vector couple, 22 the coupling
39
+ // coefficient in the q reduction, 23 the couple of the parent's offset r
40
+ #ifndef X14ADJ_PLANT
41
+ #define X14ADJ_PLANT 0
42
+ #endif
43
+
44
+ namespace d16::x14adj {
45
+
46
+ // the message / accumulator words: wbar 0, albar 3, aobar 6, lwbar 9, lobar 12, W force 15, W torque about O 18, and the rows'
47
+ // chains (rows14): vobar 21 (the origin velocity), wabar 24 and voabar 27 (the twist of a* taken as joint velocities)
48
+ constexpr int kMsg = 30;
49
+ constexpr int kMW = 0, kMAL = 3, kMAO = 6, kMLW = 9, kMLO = 12, kMF = 15, kMT = 18, kMVO = 21, kMWA = 24, kMVOA = 27;
50
+
51
+ // D16_T14_DEVLAYOUT (2026-11-08; tools/d16_bodies/ADJ_RESIDENCY.md stage A): for a phase B body, in every nvcc pass (and the CPU stand-in), Tree14 holds
52
+ // the frames as views into the record's POSE block instead of arrays (A2: k_adj14 reads them in place, 2,968 B less shared memory on the 416) and drops the
53
+ // host-only Lb (A1: the launch's host-pass sizeof is then the device's layout). A view is read-only, so a frame writer (tree14_pose: the host build, rew14)
54
+ // does not compile under it. Unset for the 14x and every host build: the arrays and Lb as before.
55
+ // D16_X14_ADJ5 (2026-11-08; tools/d16_bodies/up/PREREG_X14ADJ5.md, 1a's five conditions): the same layout for the 14x's k_adj14, the lever to 5 worlds
56
+ // per SM; a compile-time macro that no paper, paper_package or bench_final build sets (engine14.load_ext's adj5, the gate tools' --adj5).
57
+ #if defined(D16_X14_ADJ5) && defined(D16_NV_GT64)
58
+ #error "D16_X14_ADJ5 is the 14x's (NV <= 64) k_adj14 residency lever; a phase B body has stage A already"
59
+ #endif
60
+ #if (defined(D16_NV_GT64) || defined(D16_X14_ADJ5)) && defined(__CUDACC__)
61
+ #define D16_T14_DEVLAYOUT 1
62
+ template <class T, int W> struct T14Frames { // body b's W words of the record's POSE block (xpos: W 3 from POSE; xquat: W 4 from POSE + 3 NB)
63
+ const T* p;
64
+ #if defined(D16_X14_ADJ5) && X14ADJ_PLANT == 81 // (plant 81, the gates' build only: body 10 reads body 9's frame)
65
+ DN_HOST_DEVICE const T* operator[](int b) const { return p + W * (b == 10 ? 9 : b); }
66
+ #else
67
+ DN_HOST_DEVICE const T* operator[](int b) const { return p + W * b; }
68
+ #endif
69
+ };
70
+ #endif
71
+
72
+ template <class T> struct Tree14 {
73
+ T q[NQ], v[NV], a[NV], lam[NV];
74
+ #if defined(D16_T14_DEVLAYOUT)
75
+ T14Frames<T, 3> xpos;
76
+ T14Frames<T, 4> xquat;
77
+ #else
78
+ T xpos[NB][3], xquat[NB][4];
79
+ #endif
80
+ T w[NB][3], al[NB][3], ao[NB][3], lw[NB][3], lo[NB][3];
81
+ T vo[NB][3], wa[NB][3], voa[NB][3]; // the rows' chains: vo_b = vo_p + w_p x r; wa_b = wa_p + swa; voa_b = voa_p + wa_p x r
82
+ T acc[NB][kMsg]; // each body's cotangent words (LOCAL's, the rows', then UP's stages)
83
+ T xb[NE], vb[NE]; // the expanded dofs' tangent and rate cotangents
84
+ #if !defined(__CUDA_ARCH__) && !defined(D16_T14_DEVLAYOUT)
85
+ T Lb[NB]; // each body's L_b (the host gates' value check; not in the device build: lever 2)
86
+ #endif
87
+ };
88
+
89
+ template <class T> DN_HOST_DEVICE inline const T* bodyv(const T* V, int b) { return V + MD::O_BODY + 21 * b; }
90
+
91
+ // the joint's local rotation (composed with the body's fixed rotation; root: unused) and its rates in the body frame (kernel P's
92
+ // local_body, with the accelerations and lam beside the velocities), recomputed where needed (DOWN and UP) instead of stored
93
+ template <class T>
94
+ DN_HOST_DEVICE inline void t14_joint(const Tree14<T>& s, const T* V, int b, T* qrel, T* sl, T* sla, T* sll) {
95
+ using std::sin; using std::cos;
96
+ const int jt = X14T(Jtype)[b];
97
+ const T* bv = bodyv(V, b);
98
+ const int da = X14T(Dadr)[b];
99
+ if (jt == 0) { // the free root: its frame from qpos in DOWN
100
+ for (int k = 0; k < 3; ++k) { sl[k] = s.v[da + 3 + k]; sla[k] = s.a[da + 3 + k]; sll[k] = s.lam[da + 3 + k]; }
101
+ return;
102
+ }
103
+ if (jt == 3) {
104
+ const int e0 = X14T(J0)[b], m = X14T(Rsrc)[b];
105
+ const T c = V[MD::O_ECOEF + e0], ax[3] = {bv[7], bv[8], bv[9]};
106
+ for (int k = 0; k < 3; ++k) { sl[k] = ax[k] * (c * s.v[m]); sla[k] = ax[k] * (c * s.a[m]); sll[k] = ax[k] * (c * s.lam[m]); }
107
+ if (qrel) {
108
+ const T half = c * s.q[X14T(Qsrc)[b]] * T(0.5), sh = sin(half), ch = cos(half);
109
+ const T bq[4] = {bv[3], bv[4], bv[5], bv[6]}, ql[4] = {ch, ax[0] * sh, ax[1] * sh, ax[2] * sh};
110
+ qmul(bq, ql, qrel);
111
+ }
112
+ } else { // ball
113
+ for (int k = 0; k < 3; ++k) { sl[k] = s.v[da + k]; sla[k] = s.a[da + k]; sll[k] = s.lam[da + k]; }
114
+ if (qrel) {
115
+ const int qa = X14T(Qadr)[b];
116
+ T ql[4] = {s.q[qa], s.q[qa + 1], s.q[qa + 2], s.q[qa + 3]};
117
+ qnorm(ql);
118
+ const T bq[4] = {bv[3], bv[4], bv[5], bv[6]};
119
+ qmul(bq, ql, qrel);
120
+ }
121
+ }
122
+ }
123
+
124
+ // LOCAL for one body: L_b and its cotangents into acc[b] (initialized here; the children's messages are added in UP)
125
+ template <class T> DN_HOST_DEVICE inline void t14_local_bar(Tree14<T>& s, const T* V, int b, bool ne = true) {
126
+ const T* bv = bodyv(V, b);
127
+ const T m = bv[20];
128
+ T R[9], Ri[9], qq[4];
129
+ const T iq[4] = {bv[13], bv[14], bv[15], bv[16]}, ip[3] = {bv[10], bv[11], bv[12]}, d3[3] = {bv[17], bv[18], bv[19]};
130
+ qmat(s.xquat[b], R);
131
+ qmul(s.xquat[b], iq, qq);
132
+ qmat(qq, Ri);
133
+ T rc[3];
134
+ mv(R, ip, rc);
135
+ T I[6]; // Ri diag(d3) Ri' (kernel P's jfn_body)
136
+ I[0] = Ri[0] * Ri[0] * d3[0] + Ri[1] * Ri[1] * d3[1] + Ri[2] * Ri[2] * d3[2];
137
+ I[1] = Ri[3] * Ri[3] * d3[0] + Ri[4] * Ri[4] * d3[1] + Ri[5] * Ri[5] * d3[2];
138
+ I[2] = Ri[6] * Ri[6] * d3[0] + Ri[7] * Ri[7] * d3[1] + Ri[8] * Ri[8] * d3[2];
139
+ I[3] = Ri[0] * Ri[3] * d3[0] + Ri[1] * Ri[4] * d3[1] + Ri[2] * Ri[5] * d3[2];
140
+ I[4] = Ri[0] * Ri[6] * d3[0] + Ri[1] * Ri[7] * d3[1] + Ri[2] * Ri[8] * d3[2];
141
+ I[5] = Ri[3] * Ri[6] * d3[0] + Ri[4] * Ri[7] * d3[1] + Ri[5] * Ri[8] * d3[2];
142
+ const T *w = s.w[b], *al = s.al[b], *ao = s.ao[b], *lw = s.lw[b], *lo = s.lo[b];
143
+ T wr[3], wwr[3], alr[3], acom[3], f[3], Iw[3], Ia[3], wIw[3], N[3], u[3], lr[3];
144
+ crs(w, rc, wr); crs(w, wr, wwr); crs(al, rc, alr);
145
+ for (int k = 0; k < 3; ++k) { acom[k] = ao[k] + alr[k] + wwr[k]; f[k] = m * acom[k]; }
146
+ symv(I, w, Iw); symv(I, al, Ia); crs(w, Iw, wIw);
147
+ for (int k = 0; k < 3; ++k) N[k] = Ia[k] + wIw[k];
148
+ crs(lw, rc, lr);
149
+ for (int k = 0; k < 3; ++k) u[k] = lo[k] + lr[k];
150
+ #if !defined(__CUDA_ARCH__) && !defined(D16_T14_DEVLAYOUT)
151
+ s.Lb[b] = dot3(lw, N) + dot3(u, f);
152
+ #endif
153
+ // cotangents: fbar = u, Nbar = lw
154
+ T* g = s.acc[b];
155
+ for (int k = 0; k < kMsg; ++k) g[k] = T(0);
156
+ if (!ne) return; // (the rows' gate: the tree's Newton-Euler term off)
157
+ T rcb[3] = {T(0), T(0), T(0)};
158
+ // u = lo + lw x rc (ubar = f)
159
+ for (int k = 0; k < 3; ++k) g[kMLO + k] = f[k];
160
+ add_crs(g + kMLW, rc, f); // lwbar += rc x f
161
+ add_crs(rcb, f, lw); // rcbar += f x lw
162
+ add3(g + kMLW, N); // lwbar += N (from lw . N)
163
+ // f = m acom: acombar = m u
164
+ T ab[3] = {m * u[0], m * u[1], m * u[2]};
165
+ add3(g + kMAO, ab); // aobar += acombar
166
+ add_crs(g + kMAL, rc, ab); // albar += rc x acombar
167
+ add_crs(rcb, ab, al); // rcbar += acombar x al
168
+ wwr_bar(w, rc, ab, g + kMW, rcb);
169
+ // N = I al + w x (I w), Nbar = lw
170
+ T t[3];
171
+ symv(I, lw, t); add3(g + kMAL, t); // albar += I lw
172
+ add_crs(g + kMW, Iw, lw); // wbar += (I w) x lw
173
+ T lxw[3]; crs(lw, w, lxw); symv(I, lxw, t); add3(g + kMW, t); // wbar += I (lw x w)
174
+ // the frame's rotation cotangent (a couple): rc x rcbar, plus I's: Ibar = lw al' + (lw x w) w', A = I Ibar' - Ibar' I,
175
+ // rho += (A23 - A32, A31 - A13, A12 - A21)
176
+ T* tq = g + kMT;
177
+ add_crs(tq, rc, rcb);
178
+ {
179
+ T Ib[9];
180
+ for (int i = 0; i < 3; ++i)
181
+ for (int j = 0; j < 3; ++j) Ib[3 * i + j] = lw[i] * al[j] + lxw[i] * w[j];
182
+ const T Im[9] = {I[0], I[3], I[4], I[3], I[1], I[5], I[4], I[5], I[2]};
183
+ T A[9];
184
+ for (int i = 0; i < 3; ++i)
185
+ for (int j = 0; j < 3; ++j) {
186
+ T x = T(0);
187
+ for (int k = 0; k < 3; ++k) x = x + Im[3 * i + k] * Ib[3 * j + k] - Ib[3 * k + i] * Im[3 * k + j];
188
+ A[3 * i + j] = x;
189
+ }
190
+ tq[0] = tq[0] + (A[5] - A[7]); tq[1] = tq[1] + (A[6] - A[2]); tq[2] = tq[2] + (A[1] - A[3]);
191
+ }
192
+ }
193
+
194
+ // The sweep for one world in three phases (the rows' reverse, rows14_vjp, goes between LOCAL and UP), given s.q, s.v, s.a,
195
+ // s.lam: DOWN (the poses and every chain), LOCAL (the tree's L_b cotangents into s.acc; ne false: zero, the rows' gate), UP
196
+ // (the reverse sweep and the reduction: ADDS the cotangents into qbar (tangent chart) and vbar; s.Lb holds the bodies' L_b)
197
+ // lever 1 (PLAN.md "Lever 1"): DOWN as prefix sums. Given the frames (the device reads the record's POSE block, k_pre14's; the
198
+ // host builds compute them by levels below, the same arithmetic as before), every chain is a sum along the root path of a
199
+ // per-body increment, in three dependency stages:
200
+ // B: w, lw, wa;
201
+ // C: al (w_p x sw + swa), lo (lw_p x r), vo (w_p x r), voa (wa_p x r);
202
+ // D: ao (al_p x r + w_p x (w_p x r)).
203
+ // Each stage runs as kNR in-place Hillis-Steele rounds over the bodies 2..65 (the root, body 1, is the base): read the 2^r-th
204
+ // ancestor's partial (all slots first), sync, add, sync. The device holds 2 slots per lane (b = 2 + lane + 32 s), the host 64 in
205
+ // order, with the same per-element arithmetic, so the host and device builds agree bitwise. The ancestor table is per lane in
206
+ // registers, from the coalesced global gAnc14 [kNR][2][32] the launcher fills (a lane-divergent __constant__ table serializes).
207
+ // the frames by levels (the arithmetic of the previous DOWN's pose part): the host builds' frames for the adjoint, and the
208
+ // fused env side's frames at q1 on the device (lanes over a level's bodies, a sync per level)
209
+ template <class T> DN_HOST_DEVICE inline void tree14_pose(Tree14<T>& s, const T* V, int lane = 0) {
210
+ (void)lane;
211
+ #if defined(__CUDA_ARCH__)
212
+ if (lane < 3) s.xpos[0][lane] = T(0);
213
+ if (lane < 4) s.xquat[0][lane] = T(lane == 0 ? 1 : 0);
214
+ __syncwarp();
215
+ #else
216
+ s.xpos[0][0] = s.xpos[0][1] = s.xpos[0][2] = T(0); s.xquat[0][0] = T(1); s.xquat[0][1] = s.xquat[0][2] = s.xquat[0][3] = T(0);
217
+ #endif
218
+ for (int l = 0; l < NLEV; ++l) {
219
+ const int o0 = X14T(LevOff)[l], o1 = X14T(LevOff)[l + 1];
220
+ X14_FOR(ii, o1 - o0) {
221
+ const int i = o0 + ii;
222
+ const int b = X14T(LevBody)[i], jt = X14T(Jtype)[b], p = X14T(Parent)[b];
223
+ T qb[4];
224
+ if (jt == 0) {
225
+ const int qa = X14T(Qadr)[b];
226
+ for (int k = 0; k < 3; ++k) s.xpos[b][k] = s.q[qa + k];
227
+ for (int k = 0; k < 4; ++k) qb[k] = s.q[qa + 3 + k];
228
+ qnorm(qb);
229
+ } else {
230
+ T qrel[4], sl[3], sla[3], sll[3], Rp[9], r[3];
231
+ t14_joint<T>(s, V, b, qrel, sl, sla, sll);
232
+ const T* bv = bodyv(V, b);
233
+ const T pos[3] = {bv[0], bv[1], bv[2]};
234
+ qmat(s.xquat[p], Rp);
235
+ mv(Rp, pos, r);
236
+ for (int k = 0; k < 3; ++k) s.xpos[b][k] = s.xpos[p][k] + r[k];
237
+ qmul(s.xquat[p], qrel, qb);
238
+ qnorm(qb);
239
+ }
240
+ for (int k = 0; k < 4; ++k) s.xquat[b][k] = qb[k];
241
+ }
242
+ X14_SYNC();
243
+ }
244
+ }
245
+ // the chains from the frames: the root's base values on one lane, the increments, the three scan stages
246
+ template <class T> DN_HOST_DEVICE inline void tree14_chains(Tree14<T>& s, const T* V, int lane) {
247
+ (void)lane;
248
+ int A[kNR][kNS];
249
+ t14_anc_load<T>(A, lane);
250
+ #if defined(__CUDA_ARCH__)
251
+ if (lane == 0)
252
+ #endif
253
+ {
254
+ const int b = 1, da = X14T(Dadr)[b];
255
+ T sl[3], sla[3], sll[3], R[9], sw[3], swa[3], swl[3];
256
+ t14_joint<T>(s, V, b, nullptr, sl, sla, sll);
257
+ qmat(s.xquat[b], R);
258
+ mv(R, sl, sw); mv(R, sla, swa); mv(R, sll, swl);
259
+ for (int k = 0; k < 3; ++k) {
260
+ s.w[b][k] = sw[k]; s.al[b][k] = swa[k]; s.ao[b][k] = s.a[da + k] - V[MD::O_GRAVITY + k];
261
+ s.lw[b][k] = swl[k]; s.lo[b][k] = s.lam[da + k];
262
+ s.vo[b][k] = s.v[da + k]; s.wa[b][k] = swa[k]; s.voa[b][k] = s.a[da + k];
263
+ }
264
+ }
265
+ T rr[kNS][3], sw[kNS][3], swa[kNS][3];
266
+ X14_SLOTS(i, b) {
267
+ const T* bv = bodyv(V, b);
268
+ const T pos[3] = {bv[0], bv[1], bv[2]};
269
+ T sl[3], sla[3], sll[3], R[9], Rp[9], swl[3];
270
+ t14_joint<T>(s, V, b, nullptr, sl, sla, sll);
271
+ qmat(s.xquat[b], R);
272
+ qmat(s.xquat[A[0][i]], Rp); // A[0]: the parent (>= 1 for bodies 2..65)
273
+ mv(Rp, pos, rr[i]);
274
+ mv(R, sl, sw[i]); mv(R, sla, swa[i]); mv(R, sll, swl);
275
+ for (int k = 0; k < 3; ++k) { s.w[b][k] = sw[i][k]; s.lw[b][k] = swl[k]; s.wa[b][k] = swa[i][k]; }
276
+ }
277
+ X14_SYNC();
278
+ { T (*const xb[3])[3] = {s.w, s.lw, s.wa}; t14_scan<T, 3>(xb, A, lane); }
279
+ X14_SLOTS(i, b) {
280
+ const int p = A[0][i];
281
+ T ws[3], lr[3], wr[3], war[3];
282
+ crs(s.w[p], sw[i], ws); crs(s.lw[p], rr[i], lr); crs(s.w[p], rr[i], wr); crs(s.wa[p], rr[i], war);
283
+ for (int k = 0; k < 3; ++k) { s.al[b][k] = ws[k] + swa[i][k]; s.lo[b][k] = lr[k]; s.vo[b][k] = wr[k]; s.voa[b][k] = war[k]; }
284
+ }
285
+ X14_SYNC();
286
+ { T (*const xc[4])[3] = {s.al, s.lo, s.vo, s.voa}; t14_scan<T, 4>(xc, A, lane); }
287
+ X14_SLOTS(i, b) {
288
+ const int p = A[0][i];
289
+ T alr[3], wr[3], wwr[3];
290
+ crs(s.al[p], rr[i], alr); crs(s.w[p], rr[i], wr); crs(s.w[p], wr, wwr);
291
+ for (int k = 0; k < 3; ++k) s.ao[b][k] = alr[k] + wwr[k];
292
+ }
293
+ X14_SYNC();
294
+ { T (*const xd[1])[3] = {s.ao}; t14_scan<T, 1>(xd, A, lane); }
295
+ }
296
+ template <class T> DN_HOST_DEVICE inline void tree14_down(Tree14<T>& s, const T* V, int lane) {
297
+ #if !defined(__CUDA_ARCH__) && !defined(D16_T14_DEVLAYOUT)
298
+ tree14_pose(s, V); // the device reads the record's POSE block instead (k_adj14)
299
+ #endif
300
+ tree14_chains(s, V, lane);
301
+ }
302
+ template <class T> DN_HOST_DEVICE inline void tree14_local(Tree14<T>& s, const T* V, bool ne, int lane) {
303
+ (void)lane;
304
+ X14_FOR(i, NB - 1) t14_local_bar(s, V, i + 1, ne);
305
+ X14_SYNC();
306
+ }
307
+ #if defined(D16_BODY_UP_SWEEP) // U2 (2026-11-08; tools/d16_bodies/up/PREREG_U2.md): a phase B body's UP as one fused level sweep
308
+ } // namespace d16::x14adj
309
+ #include "sweep14.h"
310
+ namespace d16::x14adj {
311
+ #endif
312
+ // lever 1 stage 2: UP as the transpose of DOWN's prefix sums. Each chain's cotangent at b is the subtree sum of the local
313
+ // cotangents (LOCAL's, the rows', and the children's increment reverses), by kNR transposed rounds over the bodies 2..65 (gather
314
+ // from the 2^r-th descendants, fan-in <= 2, rounds kNR - 1 .. 0; the root's totals are its own plus its 3 children's subtree
315
+ // sums, on one lane). Stages in reverse order, each: the gather, then each body's increment reverse (its parent's local
316
+ // cotangents into a free chain array: ao / lo / vo / voa are dead in UP; its own rbar in registers), then the children gather of
317
+ // those into the parents' accumulators:
318
+ // ao -> the parent's al (r x aobar), w (wwr_bar); rbar += aobar x al_p + wwr's
319
+ // al / lo / vo / voa -> the parent's w (r x vobar + sw x albar), wa (r x voabar), lw (r x lobar); rbar += the three couples
320
+ // w / lw / wa -> the joint vectors' cotangents, the own couple into the own wrench, the rates' cotangents; the couple r x rbar
321
+ // into the parent's wrench
322
+ // the wrench (force, torque about O) -> the joints' tangent projections
323
+ template <class T>
324
+ DN_HOST_DEVICE inline void tree14_up(Tree14<T>& s, const T* V, T* qbar, T* vbar, int lane, long long* prof = nullptr) {
325
+ (void)lane; (void)prof;
326
+ #if defined(D16_BODY_UP_SWEEP)
327
+ t14_up_sweep<T>(s, V, lane);
328
+ X14_MARK(prof, 9); // (the sweep in mark 9; marks 8, 10, 11, 12 read 0)
329
+ #else
330
+ int A[kNR][kNS], D[kNR][kNS];
331
+ t14_anc_load<T>(A, lane);
332
+ t14_desc_load<T>(D, lane);
333
+ T rr[kNS][3], sw[kNS][3], swa[kNS][3], swl[kNS][3], rbar[kNS][3];
334
+ X14_SLOTS(i, b) {
335
+ // UPSEG setup
336
+ const T* bv = bodyv(V, b);
337
+ const T pos[3] = {bv[0], bv[1], bv[2]};
338
+ T sl[3], sla[3], sll[3], R[9], Rp[9];
339
+ t14_joint<T>(s, V, b, nullptr, sl, sla, sll);
340
+ qmat(s.xquat[b], R);
341
+ qmat(s.xquat[A[0][i]], Rp);
342
+ mv(Rp, pos, rr[i]);
343
+ mv(R, sl, sw[i]); mv(R, sla, swa[i]); mv(R, sll, swl[i]);
344
+ for (int k = 0; k < 3; ++k) rbar[i][k] = T(0);
345
+ // UPSEG end
346
+ }
347
+ X14_MARK(prof, 8); // (the marks: 8 setup, 9 ao, 10 al / lo / vo / voa, 11 w / lw / wa + the root, 12 the wrench, 13 the reduction)
348
+ // ao
349
+ { const int o[1] = {kMAO}; t14_gather<T, 1, kMsg>(s.acc, o, D, lane); }
350
+ X14_SLOTS(i, b) {
351
+ const int p = A[0][i];
352
+ // UPSEG ao
353
+ const T* ab = s.acc[b] + kMAO;
354
+ T cal[3] = {T(0), T(0), T(0)}, cw[3] = {T(0), T(0), T(0)};
355
+ add_crs(cal, rr[i], ab); // alpbar += r x aobar
356
+ add_crs(rbar[i], ab, s.al[p]); // rbar += aobar x alp
357
+ wwr_bar(s.w[p], rr[i], ab, cw, rbar[i]);
358
+ for (int k = 0; k < 3; ++k) { s.ao[b][k] = cal[k]; s.lo[b][k] = cw[k]; }
359
+ // UPSEG end
360
+ }
361
+ X14_SYNC();
362
+ t14_kids_add<T, kMsg>(s.acc, kMAL, s.ao, D, lane);
363
+ t14_kids_add<T, kMsg>(s.acc, kMW, s.lo, D, lane);
364
+ X14_SYNC();
365
+ X14_MARK(prof, 9);
366
+ // al, lo, vo, voa
367
+ { const int o[4] = {kMAL, kMLO, kMVO, kMVOA}; t14_gather<T, 4, kMsg>(s.acc, o, D, lane); }
368
+ X14_SLOTS(i, b) {
369
+ const int p = A[0][i];
370
+ const T* g = s.acc[b];
371
+ // UPSEG al
372
+ T cw[3] = {T(0), T(0), T(0)}, cwa[3] = {T(0), T(0), T(0)}, clw[3] = {T(0), T(0), T(0)};
373
+ add_crs(cw, rr[i], g + kMVO); // wpbar += r x vobar
374
+ add_crs(rbar[i], g + kMVO, s.w[p]); // rbar += vobar x wp
375
+ add_crs(cwa, rr[i], g + kMVOA); // wapbar += r x voabar
376
+ add_crs(rbar[i], g + kMVOA, s.wa[p]); // rbar += voabar x wap
377
+ add_crs(cw, sw[i], g + kMAL); // wpbar += sw x albar
378
+ add_crs(clw, rr[i], g + kMLO); // lwpbar += r x lobar
379
+ add_crs(rbar[i], g + kMLO, s.lw[p]); // rbar += lobar x lwp
380
+ for (int k = 0; k < 3; ++k) { s.ao[b][k] = cw[k]; s.vo[b][k] = cwa[k]; s.voa[b][k] = clw[k]; }
381
+ // UPSEG end
382
+ }
383
+ X14_SYNC();
384
+ t14_kids_add<T, kMsg>(s.acc, kMW, s.ao, D, lane);
385
+ t14_kids_add<T, kMsg>(s.acc, kMWA, s.vo, D, lane);
386
+ t14_kids_add<T, kMsg>(s.acc, kMLW, s.voa, D, lane);
387
+ X14_SYNC();
388
+ X14_MARK(prof, 10);
389
+ // w, lw, wa: the joint vectors' cotangents, the own couple, the rates; the couple of r into the parent's wrench
390
+ { const int o[3] = {kMW, kMLW, kMWA}; t14_gather<T, 3, kMsg>(s.acc, o, D, lane); }
391
+ X14_SLOTS(i, b) {
392
+ const int p = A[0][i], jt = X14T(Jtype)[b], e0 = X14T(J0)[b];
393
+ T* g = s.acc[b];
394
+ // UPSEG w
395
+ T swb[3], swab[3], swlb[3], Wt[3] = {T(0), T(0), T(0)}, R[9], rv[3], cr[3] = {T(0), T(0), T(0)};
396
+ for (int k = 0; k < 3; ++k) { swb[k] = g[kMW + k]; swab[k] = g[kMAL + k] + g[kMWA + k]; swlb[k] = g[kMLW + k]; }
397
+ add_crs(swb, g + kMAL, s.w[p]); // swbar += albar x wp
398
+ if (X14ADJ_PLANT != 21) { add_crs(Wt, sw[i], swb); add_crs(Wt, swa[i], swab); add_crs(Wt, swl[i], swlb); }
399
+ qmat(s.xquat[b], R);
400
+ mtv(R, swb, rv);
401
+ if (jt == 3) {
402
+ const T* bv = bodyv(V, b);
403
+ const T ax[3] = {bv[7], bv[8], bv[9]};
404
+ s.vb[e0] = dot3(ax, rv);
405
+ } else {
406
+ for (int k = 0; k < 3; ++k) s.vb[e0 + k] = rv[k];
407
+ }
408
+ for (int k = 0; k < 3; ++k) g[kMT + k] = g[kMT + k] + Wt[k];
409
+ if (X14ADJ_PLANT != 23) add_crs(cr, rr[i], rbar[i]); // r is attached to the parent's frame: its couple
410
+ for (int k = 0; k < 3; ++k) s.lo[b][k] = cr[k];
411
+ // UPSEG end
412
+ }
413
+ #if defined(__CUDA_ARCH__)
414
+ if (lane == 0)
415
+ #endif
416
+ { // the root: its own and its children's subtree totals (no parent term in al)
417
+ // UPSEG root_w
418
+ const int b = 1, e0 = X14T(J0)[b];
419
+ T sl[3], sla[3], sll[3], R[9], rsw[3], rswa[3], rswl[3], swb[3], swab[3], swlb[3], t1[3], t2[3], Wt[3] = {T(0), T(0), T(0)};
420
+ t14_joint<T>(s, V, b, nullptr, sl, sla, sll);
421
+ qmat(s.xquat[b], R);
422
+ mv(R, sl, rsw); mv(R, sla, rswa); mv(R, sll, rswl);
423
+ t14_root_tot<T, kMsg>(s.acc, kMW, swb);
424
+ t14_root_tot<T, kMsg>(s.acc, kMAL, t1); t14_root_tot<T, kMsg>(s.acc, kMWA, t2);
425
+ for (int k = 0; k < 3; ++k) swab[k] = t1[k] + t2[k];
426
+ t14_root_tot<T, kMsg>(s.acc, kMLW, swlb);
427
+ if (X14ADJ_PLANT != 21) { add_crs(Wt, rsw, swb); add_crs(Wt, rswa, swab); add_crs(Wt, rswl, swlb); }
428
+ T rv[3], vo[3];
429
+ mtv(R, swb, rv);
430
+ t14_root_tot<T, kMsg>(s.acc, kMVO, vo);
431
+ for (int k = 0; k < 3; ++k) { s.vb[e0 + k] = vo[k]; s.vb[e0 + 3 + k] = rv[k]; s.acc[b][kMT + k] = s.acc[b][kMT + k] + Wt[k]; }
432
+ // UPSEG end
433
+ }
434
+ X14_SYNC();
435
+ t14_kids_add<T, kMsg>(s.acc, kMT, s.lo, D, lane);
436
+ X14_SYNC();
437
+ X14_MARK(prof, 11);
438
+ // the wrench: the joints' tangent projections
439
+ { const int o[2] = {kMF, kMT}; t14_gather<T, 2, kMsg>(s.acc, o, D, lane); }
440
+ X14_SLOTS(i, b) {
441
+ (void)i;
442
+ const int jt = X14T(Jtype)[b], e0 = X14T(J0)[b];
443
+ const T* g = s.acc[b];
444
+ // UPSEG wrench
445
+ T R[9], xo[3], tb[3];
446
+ qmat(s.xquat[b], R);
447
+ for (int k = 0; k < 3; ++k) xo[k] = s.xpos[b][k] - s.xpos[1][k];
448
+ crs(xo, g + kMF, tb); // the torque about the joint point x_b: Wt - (x_b - O) x Wf
449
+ for (int k = 0; k < 3; ++k) tb[k] = g[kMT + k] - tb[k];
450
+ if (jt == 3) {
451
+ const T* bv = bodyv(V, b);
452
+ const T ax[3] = {bv[7], bv[8], bv[9]};
453
+ T aw[3];
454
+ mv(R, ax, aw);
455
+ s.xb[e0] = dot3(aw, tb);
456
+ } else {
457
+ for (int k = 0; k < 3; ++k) s.xb[e0 + k] = R[k] * tb[0] + R[3 + k] * tb[1] + R[6 + k] * tb[2];
458
+ }
459
+ // UPSEG end
460
+ }
461
+ #if defined(__CUDA_ARCH__)
462
+ if (lane == 0)
463
+ #endif
464
+ {
465
+ // UPSEG root_wrench
466
+ const int e0 = X14T(J0)[1];
467
+ T R[9], Wf[3], Wt[3];
468
+ qmat(s.xquat[1], R);
469
+ t14_root_tot<T, kMsg>(s.acc, kMF, Wf); t14_root_tot<T, kMsg>(s.acc, kMT, Wt);
470
+ for (int k = 0; k < 3; ++k) {
471
+ s.xb[e0 + k] = Wf[k]; // translation: the force
472
+ s.xb[e0 + 3 + k] = R[k] * Wt[0] + R[3 + k] * Wt[1] + R[6 + k] * Wt[2]; // (R e_k) . torque (about O = x_root)
473
+ }
474
+ // UPSEG end
475
+ }
476
+ X14_SYNC();
477
+ X14_MARK(prof, 12);
478
+ #endif
479
+ X14_FOR(d, NV) { // per reduced dof, its expanded dofs in the generated order
480
+ T sq = T(0), sv = T(0);
481
+ for (int k = X14T(BiasOff)[d]; k < X14T(BiasOff)[d + 1]; ++k) {
482
+ const int e = X14T(BiasE)[k];
483
+ const T c = V[MD::O_ECOEF + e];
484
+ sq = sq + (X14ADJ_PLANT == 22 ? T(1) : c) * s.xb[e];
485
+ sv = sv + c * s.vb[e];
486
+ }
487
+ qbar[d] = qbar[d] + sq;
488
+ vbar[d] = vbar[d] + sv;
489
+ }
490
+ X14_SYNC();
491
+ X14_MARK(prof, 13);
492
+ }
493
+ // the tree alone (tree14's gate)
494
+ template <class T> DN_HOST_DEVICE inline void tree14_vjp(Tree14<T>& s, const T* V, T* qbar, T* vbar, int lane) {
495
+ tree14_down(s, V, lane);
496
+ tree14_local(s, V, true, lane);
497
+ tree14_up(s, V, qbar, vbar, lane);
498
+ }
499
+
500
+ } // namespace d16::x14adj
@@ -0,0 +1,96 @@
1
+ #pragma once
2
+ // D16 14x adjoint (engine C, 2026-11-03; tools/d16_x14adj/PLAN.md): shared helpers for the host and the device builds of the
3
+ // same code. The model header (namespace D16_X14_NS, tools/d16_14x/gen14.py) must be included first: its tables are read as
4
+ // k* on the host and c* on the device (X14T), the values from the value pointer V (kValues' layout, the O_* offsets).
5
+ // Lanes: X14_FOR(i, n) runs i = lane, lane + 32, ... on the device and every i in order on the host; X14_SYNC() separates two
6
+ // phases (a __syncwarp on the device). Every phase writes only what its own i owns, so the host's serial order and the
7
+ // device's lanes give the same values.
8
+ #include <cassert> // JS_DEVICE_ASSERT is assert() outside the device pass
9
+ #include <cmath>
10
+
11
+ #include "diffneusim/macros.h"
12
+
13
+ #ifndef D16_X14_NS
14
+ #error "include the generated 14x model header and define D16_X14_NS before the x14adj headers"
15
+ #endif
16
+
17
+ // D16_IDX_T (11-08; up/PREREG_X14ADJ5.md): the contact indices' element type, int by default; short under D16_X14_ADJ5 (the 14x's k_adj14 at 5 per SM)
18
+ #if defined(D16_X14_ADJ5)
19
+ #define D16_IDX_T short
20
+ #else
21
+ #define D16_IDX_T int
22
+ #endif
23
+ namespace d16::x14adj {
24
+ namespace MD = D16_X14_NS;
25
+ using MD::NB; using MD::NQ; using MD::NV; using MD::NE; using MD::NLEV;
26
+
27
+ #if defined(__CUDA_ARCH__)
28
+ #define X14T(name) MD::c##name
29
+ #define X14_FOR(i, n) for (int i = lane; i < (n); i += 32)
30
+ #define X14_SYNC() __syncwarp()
31
+ #else
32
+ #define X14T(name) MD::k##name
33
+ #define X14_FOR(i, n) for (int i = 0; i < (n); ++i)
34
+ #define X14_SYNC() do { } while (0)
35
+ #endif
36
+
37
+ // X14ADJ_PROF (default off; a separately named build): lane 0 adds clock64 deltas per phase into prof[k] (k: 0 kinematics + the
38
+ // solve, 1 DOWN, 2 LOCAL, 3 rows, 4 UP's tail, 5 passive; UP's stages 8..13, tree14_up), a __syncwarp at every mark
39
+ #if defined(X14ADJ_PROF) && defined(__CUDA_ARCH__)
40
+ #define X14_MARK(prof, k) do { __syncwarp(); if (lane == 0 && (prof)) { const long long t_ = clock64(); (prof)[k] += t_ - (prof)[7]; (prof)[7] = t_; } } while (0)
41
+ #else
42
+ #define X14_MARK(prof, k) do { } while (0)
43
+ #endif
44
+
45
+ template <class T> DN_HOST_DEVICE inline void qmul(const T* a, const T* b, T* o) { // mju_mulQuat
46
+ const T w = a[0] * b[0] - a[1] * b[1] - a[2] * b[2] - a[3] * b[3];
47
+ const T x = a[0] * b[1] + a[1] * b[0] + a[2] * b[3] - a[3] * b[2];
48
+ const T y = a[0] * b[2] - a[1] * b[3] + a[2] * b[0] + a[3] * b[1];
49
+ const T z = a[0] * b[3] + a[1] * b[2] - a[2] * b[1] + a[3] * b[0];
50
+ o[0] = w; o[1] = x; o[2] = y; o[3] = z;
51
+ }
52
+ template <class T> DN_HOST_DEVICE inline void qnorm(T* q) { // mju_normalize4, as kernel P
53
+ using std::sqrt;
54
+ const T n = sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]);
55
+ if (n < T(1e-15)) { q[0] = T(1); q[1] = q[2] = q[3] = T(0); return; }
56
+ const T d = n - T(1);
57
+ if (d > T(1e-15) || d < -T(1e-15)) { const T inv = T(1) / n; for (int k = 0; k < 4; ++k) q[k] = q[k] * inv; }
58
+ }
59
+ template <class T> DN_HOST_DEVICE inline void qmat(const T* q, T* R) { // mju_quat2Mat, row-major
60
+ const T q00 = q[0] * q[0], q01 = q[0] * q[1], q02 = q[0] * q[2], q03 = q[0] * q[3];
61
+ const T q11 = q[1] * q[1], q12 = q[1] * q[2], q13 = q[1] * q[3], q22 = q[2] * q[2], q23 = q[2] * q[3], q33 = q[3] * q[3];
62
+ R[0] = q00 + q11 - q22 - q33; R[4] = q00 - q11 + q22 - q33; R[8] = q00 - q11 - q22 + q33;
63
+ R[1] = T(2) * (q12 - q03); R[2] = T(2) * (q13 + q02);
64
+ R[3] = T(2) * (q12 + q03); R[5] = T(2) * (q23 - q01);
65
+ R[6] = T(2) * (q13 - q02); R[7] = T(2) * (q23 + q01);
66
+ }
67
+ template <class T> DN_HOST_DEVICE inline void mv(const T* R, const T* v, T* o) {
68
+ for (int i = 0; i < 3; ++i) o[i] = R[3 * i] * v[0] + R[3 * i + 1] * v[1] + R[3 * i + 2] * v[2];
69
+ }
70
+ template <class T> DN_HOST_DEVICE inline void mtv(const T* R, const T* v, T* o) { // R' v
71
+ for (int i = 0; i < 3; ++i) o[i] = R[i] * v[0] + R[3 + i] * v[1] + R[6 + i] * v[2];
72
+ }
73
+ template <class T> DN_HOST_DEVICE inline void crs(const T* a, const T* b, T* o) {
74
+ const T x = a[1] * b[2] - a[2] * b[1], y = a[2] * b[0] - a[0] * b[2], z = a[0] * b[1] - a[1] * b[0];
75
+ o[0] = x; o[1] = y; o[2] = z;
76
+ }
77
+ template <class T> DN_HOST_DEVICE inline T dot3(const T* a, const T* b) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; }
78
+ template <class T> DN_HOST_DEVICE inline void add3(T* acc, const T* x) { for (int k = 0; k < 3; ++k) acc[k] = acc[k] + x[k]; }
79
+ // acc += a x b
80
+ template <class T> DN_HOST_DEVICE inline void add_crs(T* acc, const T* a, const T* b) { T t[3]; crs(a, b, t); add3(acc, t); }
81
+ // symmetric packed (xx yy zz xy xz yz) times v
82
+ template <class T> DN_HOST_DEVICE inline void symv(const T* I, const T* v, T* o) {
83
+ o[0] = I[0] * v[0] + I[3] * v[1] + I[4] * v[2];
84
+ o[1] = I[3] * v[0] + I[1] * v[1] + I[5] * v[2];
85
+ o[2] = I[4] * v[0] + I[5] * v[1] + I[2] * v[2];
86
+ }
87
+ // the cotangent of w x (w x r) (= w (w . r) - r |w|^2) against abar: added into wbar and rbar
88
+ template <class T> DN_HOST_DEVICE inline void wwr_bar(const T* w, const T* r, const T* abar, T* wbar, T* rbar) {
89
+ const T wr = dot3(w, r), aw = dot3(abar, w), ar = dot3(abar, r), ww = dot3(w, w);
90
+ for (int k = 0; k < 3; ++k) {
91
+ wbar[k] = wbar[k] + abar[k] * wr + aw * r[k] - T(2) * ar * w[k];
92
+ rbar[k] = rbar[k] + aw * w[k] - ww * abar[k];
93
+ }
94
+ }
95
+
96
+ } // namespace d16::x14adj
Binary file