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,243 @@
1
+ #pragma once
2
+ // D16 adjoint megakernel, the CUDA shell's per-world body (d5, 2026-11-02; tools/d16_adj_shell/PREREG.md): the VJP of one control
3
+ // step from its packed tape records (core/soft/tape.h), B's Chain.vjp (tools/d16_adj/vjp_chain.py) steps 1-4 per substep in
4
+ // reverse, with B's row / PD reverse as the Rows functor (stub until it lands) and adj_tree for the RNE / pose terms; the output
5
+ // pull-back (out_adj.h) once per control step. Host-emulable phases (ADJ_LANES), deterministic, no allocation, every buffer the
6
+ // caller's (CUDA-graph capturable); failures OR-ed into *flag.
7
+ #include <cstdint>
8
+
9
+ #include "../tape.h"
10
+ #if defined(__CUDACC__)
11
+ #include "../gpu/chol_rn.cuh"
12
+ #endif
13
+ #include "out_adj.h"
14
+ #include "tree_adj.h"
15
+
16
+ namespace js::soft::adj {
17
+
18
+ constexpr uint32_t kShellBadRecord = 1u << 0; // a record carries kTapeOverflow (its content is not valid)
19
+ constexpr int kNV = 35; // the G1's nv (the solves' and vectors' size)
20
+
21
+ // shell scratch words (S): the adj_tree / output scratch, the poses buffer, then the vectors
22
+ constexpr int kShVec = 14; // qb vb ub aadvb y asb lam work z acc2 rinv | staged: v q a* (36 words each)
23
+ // + the pose cotangents (2 x 3 kNB). The record's POSE block is read in place: adj_tree reads it only in its two parallel phases
24
+ // (the pre-pass and the off-chain inertia), never on the level chain, so staging it would cost residency for nothing (the
25
+ // 8.3 KB staged build ran at 10 blocks / SM and was 5% slower, 143150ef).
26
+ constexpr int kShellWords = kSlotT * kNB + kShVec * 36 + 2 * 3 * kNB;
27
+ static_assert(kSlotT * kNB >= kNV * (kNV + 1) / 2, "a staged factor must fit in adj_tree's scratch");
28
+
29
+ // The rows functor's interface: ADDS its q_bar, v_bar, u_bar and the pose cotangents (xpos_bar, xrot_bar nb x 3) of substep s.
30
+ // The kernel binds it per world: rows.bind(w, the world's records, the shell scratch, the world's flag word) returns the functor
31
+ // adj_control_step calls (B's RowsBFactory binds the records, foot friction, scratch and flag). Scratch lifetime: B's RowsB
32
+ // uses the first kRowsScratch (1,088) words of the shell scratch, adj_tree's slot area. In a substep that area holds the
33
+ // staged L_Q, then L_H (steps 3-4, dead once each solve returns), RowsB's data (step 5, dead when it returns), then adj_tree's
34
+ // slots; the staged q / v / a*, y, lambda, a* - a_adv and the pose cotangents live in the vector region after it.
35
+ struct RowsStub {
36
+ template <class S> DN_HOST_DEVICE void operator()(int, const S*, const S*, const S*, const S*, S*, S*, S*, S*, S*) const {}
37
+ template <class S> DN_HOST_DEVICE RowsStub bind(int, const S*, S*, uint32_t*) const { return *this; }
38
+ };
39
+
40
+ // G-S2's functor: B's rows reverse outputs injected per substep (data: nsub x kInjWords, [q_bar 35 | v_bar 35 | u_bar 29 |
41
+ // xpos_bar 96 | xrot_bar 96]), ADDED as B's device function will add them. A test functor; never in a production build.
42
+ constexpr int kInjWords = 35 + 35 + 29 + 96 + 96;
43
+ template <class S> struct RowsInj {
44
+ const S* data;
45
+ DN_HOST_DEVICE RowsInj bind(int, const S*, S*, uint32_t*) const { return *this; }
46
+ DN_HOST_DEVICE void operator()(int s, const S*, const S*, const S*, const S*, S* qb, S* vb, S* ub, S* xpb, S* xrb) const {
47
+ const S* d = data + static_cast<size_t>(s) * kInjWords;
48
+ ADJ_LANES(lane) {
49
+ for (int i = lane; i < 35; i += 32) { qb[i] = qb[i] + d[i]; vb[i] = vb[i] + d[35 + i]; }
50
+ for (int i = lane; i < 29; i += 32) ub[i] = ub[i] + d[70 + i];
51
+ for (int i = lane; i < 96; i += 32) { xpb[i] = xpb[i] + d[99 + i]; xrb[i] = xrb[i] + d[195 + i]; }
52
+ }
53
+ }
54
+ };
55
+
56
+ // x = (L L')^-1 b on the packed lower TRI(i, j) = L[i (i + 1) / 2 + j], one phase per column (each lane derives the pivot
57
+ // quotient itself, so no phase reads a word written in the same phase). A placeholder for the latency-optimized solve.
58
+ template <class S, class T>
59
+ DN_HOST_DEVICE inline void tri_solve(const T* L, const S* b, S* work, S* z, S* x) {
60
+ ADJ_LANES(lane) {
61
+ for (int i = lane; i < kNV; i += 32) work[i] = b[i];
62
+ }
63
+ for (int j = 0; j < kNV; ++j) { // forward: L z = b
64
+ ADJ_LANES(lane) {
65
+ const S zj = work[j] / S(L[j * (j + 1) / 2 + j]);
66
+ for (int i = lane; i < kNV; i += 32) {
67
+ if (i > j) work[i] = work[i] - S(L[i * (i + 1) / 2 + j]) * zj;
68
+ else if (i == j) z[j] = zj;
69
+ }
70
+ }
71
+ }
72
+ for (int j = kNV - 1; j >= 0; --j) { // backward: L' x = z
73
+ ADJ_LANES(lane) {
74
+ const S xj = z[j] / S(L[j * (j + 1) / 2 + j]);
75
+ for (int i = lane; i < kNV; i += 32) {
76
+ if (i < j) z[i] = z[i] - S(L[j * (j + 1) / 2 + i]) * xj;
77
+ else if (i == j) x[j] = xj;
78
+ }
79
+ }
80
+ }
81
+ }
82
+
83
+ // x = (L L')^-1 b with the factor staged in shared memory: on the device the solve (chol_rn.cuh, d6ee775c: reciprocal
84
+ // pivots, both halves column by column; the review's choice for the adjoint's L_H and, until the tree-sparse header lands, L_Q);
85
+ // on the host the placeholder column solve (the host gate's arithmetic). rinv: kNV words of scratch.
86
+ template <class S>
87
+ DN_HOST_DEVICE inline void staged_solve(const S* Ls, const S* b, S* work, S* z, S* x, S* rinv) {
88
+ #if defined(__CUDA_ARCH__)
89
+ (void)work; (void)z;
90
+ const int lane = static_cast<int>(threadIdx.x & 31u);
91
+ for (int i = lane; i < kNV; i += 32) x[i] = b[i];
92
+ js::soft::gpu::chol::set_rinv<S, kNV>(Ls, rinv, lane);
93
+ // both halves column by column (engine C, 2026-11-02, tools/d16_adj/COLSOLVE.md): one shuffle and one row load per column,
94
+ // in place of the 8-row blocks with their diagonal block on every lane (the v3j in k_post: -5.0%)
95
+ // Tag 1: the adjoint's own instantiation, so k_post's solves are compiled for k_post alone (binding v10b)
96
+ js::soft::gpu::chol::solve_fwd<S, kNV, 1>(Ls, rinv, x, lane);
97
+ js::soft::gpu::chol::solve_bwd<S, kNV, 1>(Ls, rinv, x, lane);
98
+ #else
99
+ (void)rinv;
100
+ tri_solve(Ls, b, work, z, x);
101
+ #endif
102
+ }
103
+
104
+ // copies a packed factor (ntri words) into shared memory, lane strided
105
+ template <class S> DN_HOST_DEVICE inline void stage_tri(const S* src, int ntri, S* dst) {
106
+ ADJ_LANES(lane) {
107
+ for (int k = lane; k < ntri; k += 32) dst[k] = src[k];
108
+ }
109
+ }
110
+
111
+ // One control step's VJP for one world.
112
+ // rec: the nsub records of the control step, record s at rec + s * L.words (T = the record's word, the same as S here)
113
+ // kd_dof: kd on each actuated dof (0 elsewhere); h: the timestep
114
+ // q_out, v_out: (q_{t+1}, v_{t+1}); wq (tangent 35), wv: their cotangents; out_*: the output frames' cotangents (nb x 3 each,
115
+ // nullptr for none); q_bar, v_bar, u_bar: written (not added); dbg: nsub x 3 x kNV (y, a*_bar, lambda) or nullptr
116
+ // ADJ_SECT (engine B's L5 section timers, a profiling build only; compiled out by default): lane 0 stamps clock64 into
117
+ // g_adj_sect[(world x nsub_max + substep) x kSectStamps + k] at the substep's section boundaries (k 0-5 here, 6-11 inside RowsB).
118
+ constexpr int kSectStamps = 16, kSectNsubMax = 4;
119
+ #if defined(ADJ_SECT) && defined(__CUDACC__)
120
+ __device__ long long* g_adj_sect; // declared in both nvcc passes (the host sets it with cudaMemcpyToSymbol)
121
+ #endif
122
+ #if defined(ADJ_SECT) && defined(__CUDA_ARCH__)
123
+ #define ADJ_STAMP(s, k) do { if ((threadIdx.x & 31u) == 0 && g_adj_sect) \
124
+ g_adj_sect[(static_cast<size_t>(blockIdx.x) * kSectNsubMax + (s)) * kSectStamps + (k)] = clock64(); } while (0)
125
+ #else
126
+ #define ADJ_STAMP(s, k) do {} while (0)
127
+ #endif
128
+
129
+ template <class S, class Tab, class Rows>
130
+ DN_HOST_DEVICE void adj_control_step(const Tab& B, const S* rec, const TapeLayout& L, int nsub, S h, const S* kd_dof,
131
+ const S* q_out, const S* v_out, const S* wq, const S* wv, const S* out_xpos_bar,
132
+ const S* out_xrot_bar, const S* out_vb_bar, const S* out_wb_bar, const Rows& rows,
133
+ S* q_bar, S* v_bar, S* u_bar, uint32_t* flag, S* scratch, S* dbg = nullptr) {
134
+ S* tree_scr = scratch;
135
+ S* vec = scratch + kSlotT * kNB;
136
+ S *qb = vec, *vb = vec + 36, *ub = vec + 72, *aadvb = vec + 108, *y = vec + 144, *asb = vec + 180, *lam = vec + 216,
137
+ *work = vec + 252, *z = vec + 288, *acc2 = vec + 324, *sp0 = vec + 360, *sv = vec + 396, *sq = vec + 432, *sast = vec + 468;
138
+ S* xpb = vec + kShVec * 36;
139
+ S* xrb = xpb + 3 * kNB;
140
+ // the review's rule (12:0x): no dependent global load on the chain. Every per-world vector the level sweeps read is staged in
141
+ // shared memory once, coalesced: the record's q, v, a* and POSE block per substep, (q_{t+1}, v_{t+1}) for the output pull-back
142
+ ADJ_LANES(lane) {
143
+ for (int i = lane; i < kNV; i += 32) { qb[i] = wq[i]; vb[i] = wv[i]; }
144
+ for (int i = lane; i < 36; i += 32) ub[i] = S(0);
145
+ }
146
+ // 0. the output frames' pull-back at (q_{t+1}, v_{t+1})
147
+ if (out_xpos_bar || out_xrot_bar || out_vb_bar || out_wb_bar) {
148
+ ADJ_LANES(lane) {
149
+ for (int i = lane; i < 36; i += 32) sq[i] = q_out[i];
150
+ for (int i = lane; i < kNV; i += 32) sv[i] = v_out[i];
151
+ }
152
+ adj_out_pullback<S, 0>(B, sq, sv, out_xpos_bar, out_xrot_bar, out_vb_bar, out_wb_bar, qb, vb, tree_scr);
153
+ }
154
+ for (int s = nsub - 1; s >= 0; --s) {
155
+ const S* r = rec + static_cast<size_t>(s) * L.words;
156
+ const uint32_t fl = tape_get_u(r, L.flags);
157
+ // a record with kTapeOverflow is not valid (l3.cuh tape_overflow writes only hdr and flags) and the forward HELD the state over
158
+ // that substep (l3.cuh solve: q1 = q, v1 = v), so its VJP is the identity: q_bar and v_bar pass through, u_bar gets nothing. fl is
159
+ // the same word on every lane, so the skip is warp-uniform (outside any ADJ_LANES block: every lane continues together)
160
+ if (fl & kTapeOverflow) {
161
+ ADJ_LANES(lane) {
162
+ if (lane == 0) *flag = *flag | kShellBadRecord;
163
+ }
164
+ continue;
165
+ }
166
+ const S* aadv = r + L.qadv;
167
+ const bool posed = L.npose == kNB;
168
+ ADJ_LANES(lane) {
169
+ for (int i = lane; i < 36; i += 32) sq[i] = r[L.qpos + i];
170
+ for (int i = lane; i < kNV; i += 32) { sv[i] = r[L.qvel + i]; sast[i] = r[L.qacc + i]; }
171
+ }
172
+ const S *q = sq, *v = sv, *astar = sast;
173
+ ADJ_STAMP(s, 0);
174
+ // 1. positions (the free root: dofs 0-2 translation, 3-5 rotation; a hinge dof d at qpos d + 1) and 2. velocities
175
+ ADJ_LANES(lane) {
176
+ if (lane == 3) { // the root rotation: q' = q (x) Exp(phi), phi = h w', w' = v + h a_adv (body frame)
177
+ S phi[3], t2 = S(0);
178
+ for (int k = 0; k < 3; ++k) { phi[k] = h * (v[3 + k] + h * aadv[3 + k]); t2 = t2 + phi[k] * phi[k]; }
179
+ using so3::js_sqrt; using so3::js_sin; using so3::js_cos;
180
+ const S th = js_sqrt(t2);
181
+ S c1, c2, d1, d2; // Exp = I + c1 K + c2 K^2 ; Jr = I - d1 K + d2 K^2 (K = [phi]x)
182
+ if (th < S(1e-8)) { c1 = S(1); c2 = S(0.5); d1 = S(0.5); d2 = S(1) / S(6); }
183
+ else {
184
+ const S sn = js_sin(th), cs = js_cos(th);
185
+ c1 = sn / th; c2 = (S(1) - cs) / t2; d1 = (S(1) - cs) / t2; d2 = (th - sn) / (t2 * th);
186
+ }
187
+ const S g[3] = {qb[3], qb[4], qb[5]};
188
+ S Kg[3], KKg[3];
189
+ cross3(phi, g, Kg); cross3(phi, Kg, KKg);
190
+ // Exp(phi) g -> q_bar rotation; h Jr(phi)' g = h (I + d1 K + d2 K^2) g (K' = -K) -> v_bar rotation
191
+ for (int k = 0; k < 3; ++k) {
192
+ qb[3 + k] = g[k] + c1 * Kg[k] + c2 * KKg[k];
193
+ vb[3 + k] = vb[3 + k] + h * (g[k] + d1 * Kg[k] + d2 * KKg[k]);
194
+ }
195
+ }
196
+ for (int i = lane; i < kNV; i += 32) {
197
+ if (i < 3 || i >= 6) vb[i] = vb[i] + h * qb[i]; // translation and hinges: q' = q + h v'
198
+ }
199
+ }
200
+ ADJ_LANES(lane) {
201
+ for (int i = lane; i < kNV; i += 32) aadvb[i] = h * vb[i]; // v' = v + h a_adv (v_bar passes through)
202
+ }
203
+ // 3. y = Q^-1 a_adv_bar (L_Q); a*_bar = M y = a_adv_bar - h kd (.) y on the unclamped actuated dofs. Each factor is staged in
204
+ // shared memory once (coalesced) in adj_tree's scratch, free until step 5: the solve's phases then read shared, not the record
205
+ ADJ_STAMP(s, 1);
206
+ stage_tri(r + L.LQ, L.ntri, tree_scr);
207
+ staged_solve(tree_scr, aadvb, work, z, y, sp0);
208
+ ADJ_LANES(lane) {
209
+ for (int i = lane; i < kNV; i += 32) {
210
+ const bool clamped = (tape_get_u(r, L.clamp + (i >> 5)) >> (i & 31)) & 1u;
211
+ asb[i] = clamped ? aadvb[i] : aadvb[i] - h * kd_dof[i] * y[i];
212
+ acc2[i] = astar[i] - aadv[i];
213
+ }
214
+ }
215
+ // 4. lambda = H^-1 a*_bar (L_H)
216
+ ADJ_STAMP(s, 2);
217
+ stage_tri(r + L.LH, L.ntri, tree_scr);
218
+ staged_solve(tree_scr, asb, work, z, lam, sp0);
219
+ if (dbg) {
220
+ ADJ_LANES(lane) {
221
+ for (int i = lane; i < kNV; i += 32) {
222
+ dbg[(s * 3 + 0) * kNV + i] = y[i]; dbg[(s * 3 + 1) * kNV + i] = asb[i]; dbg[(s * 3 + 2) * kNV + i] = lam[i];
223
+ }
224
+ }
225
+ }
226
+ // 5. theta: B's rows / PD reverse (adds, with the pose cotangents), then the RNE / pose sweep
227
+ ADJ_LANES(lane) {
228
+ for (int i = lane; i < 3 * kNB; i += 32) { xpb[i] = S(0); xrb[i] = S(0); }
229
+ }
230
+ ADJ_STAMP(s, 3);
231
+ rows(s, q, v, lam, astar, qb, vb, ub, xpb, xrb);
232
+ ADJ_STAMP(s, 4);
233
+ const S* pose = posed ? r + L.pose : nullptr;
234
+ adj_tree<S>(B, q, v, astar, acc2, lam, S(-1), y, S(1), xpb, xrb, qb, vb, tree_scr, nullptr, pose);
235
+ ADJ_STAMP(s, 5);
236
+ }
237
+ ADJ_LANES(lane) {
238
+ for (int i = lane; i < kNV; i += 32) { q_bar[i] = qb[i]; v_bar[i] = vb[i]; }
239
+ for (int i = lane; i < 29; i += 32) u_bar[i] = ub[i];
240
+ }
241
+ }
242
+
243
+ } // namespace js::soft::adj
@@ -0,0 +1,356 @@
1
+ #pragma once
2
+ // D16 adjoint, the contact-free reverse half FUSED into one tree sweep per substep (d5, 2026-11-02; prediction and gate in
3
+ // tools/d16_adj_rnea/PREREG.md, "Section split ... and the fused version's prediction"). adj_tree adds, in one root-to-leaf and
4
+ // one leaf-to-root sweep, the sum of what B's three calls per substep add:
5
+ // coef1 d/d(q, v) [seed1' RNEA(q, v, acc1)] with gravity (channel 1: B's (q, v, a*, gravity, lambda, -1))
6
+ // coef2 d/d q [seed2' RNEA(q, 0, acc2)] without gravity (channel 2: B's (q, null, a* - a_adv, y, +1))
7
+ // the pull-back of xpos_bar / xrot_bar through fk (B's pose cotangents of the substep)
8
+ // NablaEngine's organization (adjoint.py A3 / A4 / A7): the poses once, both channels as two interleaved chains on the levels,
9
+ // each body's own terms off the chain in one phase with all lanes active, then one reverse sweep with a 33-word message.
10
+ // The math of each term is rnea_adj.h's (gated there against kin.h in Dual); this file only reorganizes it.
11
+ #include "rnea_adj.h"
12
+
13
+ namespace js::soft::adj {
14
+
15
+ constexpr int kSlotT = 36; // forward publish: xq 4, xp 3, w, al, ao, wt, vot (ch 1), al2, ao2, wt2, vot2 (ch 2); 2 pad words
16
+ constexpr int kMsgT = 36; // reverse message: xpb, tau, ch 1 (wb, alb, aob, wtb, vtb), ch 2 (alb2, aob2, wtb2, vtb2); 3 pad
17
+ constexpr int kMaxKids = 4; // children per body held in registers (the G1: at most 3)
18
+
19
+ // The pose input's layout, in one place (the review: fixes ONE layout in tape.h): SoA as kernel P's hand, xpos [kNB][3] at word 0,
20
+ // then xquat [kNB][4]; the world's row holds the identity.
21
+ constexpr int kPoseXpos = 0, kPoseXquat = 3 * kNB, kPoseWords = 7 * kNB;
22
+ template <class S> DN_HOST_DEVICE inline const S* pose_xpos(const S* pose, int b) { return pose + kPoseXpos + 3 * b; }
23
+ template <class S> DN_HOST_DEVICE inline const S* pose_xquat(const S* pose, int b) { return pose + kPoseXquat + 4 * b; }
24
+ template <class S> DN_HOST_DEVICE inline S* pose_xpos(S* pose, int b) { return pose + kPoseXpos + 3 * b; }
25
+ template <class S> DN_HOST_DEVICE inline S* pose_xquat(S* pose, int b) { return pose + kPoseXquat + 4 * b; }
26
+
27
+ // 36-word row operations: float4 on the device for float (rows are 144-byte aligned), word by word elsewhere. Pure data movement
28
+ // and the same additions in the same order, so the results are bitwise those of the word-by-word loop.
29
+ template <class S> DN_HOST_DEVICE inline void add_row36(S* acc, const S* m) {
30
+ #if defined(__CUDA_ARCH__)
31
+ if constexpr (std::is_same<S, float>::value) {
32
+ const float4* m4 = reinterpret_cast<const float4*>(m);
33
+ #pragma unroll
34
+ for (int i = 0; i < 9; ++i) {
35
+ const float4 x = m4[i];
36
+ acc[4 * i] = acc[4 * i] + x.x; acc[4 * i + 1] = acc[4 * i + 1] + x.y; acc[4 * i + 2] = acc[4 * i + 2] + x.z;
37
+ acc[4 * i + 3] = acc[4 * i + 3] + x.w;
38
+ }
39
+ return;
40
+ }
41
+ #endif
42
+ for (int k = 0; k < 36; ++k) acc[k] = acc[k] + m[k];
43
+ }
44
+ template <class S> DN_HOST_DEVICE inline void store_row36(S* dst, const S* src) {
45
+ #if defined(__CUDA_ARCH__)
46
+ if constexpr (std::is_same<S, float>::value) {
47
+ float4* d4 = reinterpret_cast<float4*>(dst);
48
+ #pragma unroll
49
+ for (int i = 0; i < 9; ++i) d4[i] = make_float4(src[4 * i], src[4 * i + 1], src[4 * i + 2], src[4 * i + 3]);
50
+ return;
51
+ }
52
+ #endif
53
+ for (int k = 0; k < 36; ++k) dst[k] = src[k];
54
+ }
55
+
56
+
57
+ // R, r = X_b - X_p as the forward forms it (R_p pos), and the hinge axis a = R axis, from the poses (xq, xp) of the body and
58
+ // (pq) of its parent: what body_kin derives besides the pose itself, so a given pose gives bitwise body_kin's values.
59
+ template <class S, class Tab>
60
+ DN_HOST_DEVICE inline void body_pose_derived(const Tab& B, int b, const S* xq, const S* pq, S* R, S* r, S* a) {
61
+ const int jt = B.jnt(b);
62
+ if (jt == kJntFree) {
63
+ r[0] = r[1] = r[2] = S(0);
64
+ } else {
65
+ #if defined(__CUDA_ARCH__)
66
+ if constexpr (std::is_same<S, float>::value) {
67
+ d16::qrot_rn(pq, B.pos(b), r);
68
+ } else
69
+ #endif
70
+ {
71
+ S Rp[9];
72
+ quat_to_mat(pq, Rp);
73
+ mat_vec(Rp, B.pos(b), r);
74
+ }
75
+ }
76
+ quat_to_mat(xq, R);
77
+ if (jt == kJntHinge) mat_vec(R, B.axis(b), a);
78
+ else a[0] = a[1] = a[2] = S(0);
79
+ }
80
+
81
+ // pose: kernel P's poses in the layout of pose_xpos / pose_xquat (kPoseWords words), or nullptr to recompute them via body_kin.
82
+ template <class S, class Tab>
83
+ DN_HOST_DEVICE void adj_tree(const Tab& B, const S* q, const S* v, const S* acc1, const S* acc2, const S* seed1, S coef1,
84
+ const S* seed2, S coef2, const S* xpos_bar, const S* xrot_bar, S* q_bar, S* v_bar, S* scratch,
85
+ long long* prof = nullptr, const S* pose = nullptr) {
86
+ (void)prof;
87
+ S (*slot)[kSlotT] = reinterpret_cast<S (*)[kSlotT]>(scratch);
88
+ const int nb = B.nb();
89
+ LANEA(S, R, 9); LANEA(S, r, 3); LANEA(S, a, 3);
90
+ LANEA(S, own, kMsgT); // the body's own cotangent terms (off the chain), the reverse sweep's starting values
91
+ LANE1(int, dep); LANE1(int, par); LANE1(int, jtl); LANE1(int, nk); LANEA(int, kid, kMaxKids);
92
+ ADJ_LANES(lane) { // each lane's structure, read once (not per level)
93
+ LV(dep) = lane < nb ? B.depth(lane) : -1;
94
+ LV(par) = lane < nb ? B.parent(lane) : 0;
95
+ LV(jtl) = lane < nb ? B.jnt(lane) : -1;
96
+ LV(nk) = lane < nb ? B.nchild(lane) : 0;
97
+ #if !defined(__CUDA_ARCH__) // the device's table is checked at compile time (adj_tab.cuh), so no device assert and no stack
98
+ assert(LV(nk) <= kMaxKids && "adj_tree holds at most kMaxKids children per body in registers");
99
+ #endif
100
+ #pragma unroll
101
+ for (int i = 0; i < kMaxKids; ++i) LV(kid)[i] = i < LV(nk) ? B.child(lane, i) : 0;
102
+ }
103
+ if (pose) { // the poses are given: R, r and a for every body at once, off the levels' chain
104
+ ADJ_LANES(lane) {
105
+ if (LV(dep) >= 1) body_pose_derived(B, lane, pose_xquat(pose, lane), pose_xquat(pose, LV(par)), LV(R), LV(r), LV(a));
106
+ }
107
+ }
108
+ ADJ_LANES(lane) {
109
+ if (lane == 0) { // the world: at rest; channel 1 has the base acceleration -gravity, channel 2 none
110
+ S* s = slot[0];
111
+ s[0] = S(1);
112
+ for (int k = 1; k < kSlotT; ++k) s[k] = S(0);
113
+ for (int k = 0; k < 3; ++k) s[13 + k] = S(0) - B.gravity(k);
114
+ }
115
+ }
116
+ // ---- A3: root-to-leaf, the poses and both channels' velocity / acceleration chains
117
+ for (int d = 1; d <= B.maxdepth(); ++d) {
118
+ ADJ_LANES(lane) {
119
+ ADJ_LEAD(LV(dep) == d);
120
+ if (LV(dep) == d) {
121
+ ADJ_TS(2 + 10 * (d - 1));
122
+ const int b = lane, jt = LV(jtl);
123
+ const S* ps = slot[LV(par)];
124
+ S* s = slot[b];
125
+ S xq[4], xp[3];
126
+ // the posed path needs no pose on the chain: R, r, a came from the pre-pass and the off-chain phase reads the pose itself
127
+ if (pose) { for (int k = 0; k < 4; ++k) xq[k] = S(0); for (int k = 0; k < 3; ++k) xp[k] = S(0); }
128
+ else body_kin(B, b, q, ps, ps + 4, xq, xp, LV(R), LV(r), LV(a));
129
+ ADJ_TS(3 + 10 * (d - 1));
130
+ const S *wp = ps + 7, *alp = ps + 10, *aop = ps + 13, *wtp = ps + 16, *votp = ps + 19;
131
+ const S *al2p = ps + 22, *ao2p = ps + 25, *wt2p = ps + 28, *vot2p = ps + 31;
132
+ S w[3], al[3], ao[3], wt[3], vot[3], al2[3], ao2[3], wt2[3], vot2[3], t[3];
133
+ if (jt == kJntFree) {
134
+ const int dd = B.dadr(b);
135
+ S wbody[3] = {v[dd + 3], v[dd + 4], v[dd + 5]}, a1b[3] = {acc1[dd + 3], acc1[dd + 4], acc1[dd + 5]},
136
+ a2b[3] = {acc2[dd + 3], acc2[dd + 4], acc2[dd + 5]}, s1b[3] = {seed1[dd + 3], seed1[dd + 4], seed1[dd + 5]},
137
+ s2b[3] = {seed2[dd + 3], seed2[dd + 4], seed2[dd + 5]};
138
+ mat_vec(LV(R), wbody, w);
139
+ mat_vec(LV(R), a1b, t); for (int k = 0; k < 3; ++k) al[k] = alp[k] + t[k];
140
+ mat_vec(LV(R), a2b, t); for (int k = 0; k < 3; ++k) al2[k] = al2p[k] + t[k];
141
+ mat_vec(LV(R), s1b, t); for (int k = 0; k < 3; ++k) wt[k] = wtp[k] + t[k];
142
+ mat_vec(LV(R), s2b, t); for (int k = 0; k < 3; ++k) wt2[k] = wt2p[k] + t[k];
143
+ for (int k = 0; k < 3; ++k) {
144
+ ao[k] = aop[k] + acc1[dd + k]; ao2[k] = ao2p[k] + acc2[dd + k];
145
+ vot[k] = votp[k] + seed1[dd + k]; vot2[k] = vot2p[k] + seed2[dd + k];
146
+ }
147
+ } else {
148
+ S t1[3], t2[3], t3[3];
149
+ cross3(wp, LV(r), t1); cross3(alp, LV(r), t2); cross3(wp, t1, t3);
150
+ for (int k = 0; k < 3; ++k) ao[k] = aop[k] + t2[k] + t3[k];
151
+ cross3(al2p, LV(r), t2);
152
+ for (int k = 0; k < 3; ++k) ao2[k] = ao2p[k] + t2[k];
153
+ cross3(wtp, LV(r), t1); for (int k = 0; k < 3; ++k) vot[k] = votp[k] + t1[k];
154
+ cross3(wt2p, LV(r), t1); for (int k = 0; k < 3; ++k) vot2[k] = vot2p[k] + t1[k];
155
+ if (jt == kJntHinge) {
156
+ const int dd = B.dadr(b);
157
+ const S vb = v[dd];
158
+ S sq[3], c[3];
159
+ for (int k = 0; k < 3; ++k) sq[k] = LV(a)[k] * vb;
160
+ cross3(wp, sq, c);
161
+ for (int k = 0; k < 3; ++k) {
162
+ w[k] = wp[k] + sq[k];
163
+ al[k] = alp[k] + c[k] + LV(a)[k] * acc1[dd];
164
+ wt[k] = wtp[k] + LV(a)[k] * seed1[dd];
165
+ al2[k] = al2p[k] + LV(a)[k] * acc2[dd];
166
+ wt2[k] = wt2p[k] + LV(a)[k] * seed2[dd];
167
+ }
168
+ } else {
169
+ for (int k = 0; k < 3; ++k) { w[k] = wp[k]; al[k] = alp[k]; wt[k] = wtp[k]; al2[k] = al2p[k]; wt2[k] = wt2p[k]; }
170
+ }
171
+ }
172
+ ADJ_TS(4 + 10 * (d - 1));
173
+ S pub[kSlotT];
174
+ for (int k = 0; k < 4; ++k) pub[k] = xq[k];
175
+ for (int k = 0; k < 3; ++k) {
176
+ pub[4 + k] = xp[k]; pub[7 + k] = w[k]; pub[10 + k] = al[k]; pub[13 + k] = ao[k]; pub[16 + k] = wt[k]; pub[19 + k] = vot[k];
177
+ pub[22 + k] = al2[k]; pub[25 + k] = ao2[k]; pub[28 + k] = wt2[k]; pub[31 + k] = vot2[k];
178
+ }
179
+ pub[34] = pub[35] = S(0);
180
+ store_row36(s, pub);
181
+ ADJ_TS(5 + 10 * (d - 1));
182
+ }
183
+ }
184
+ }
185
+ // ---- A4: each body's own terms, all lanes at once (off the levels' chain)
186
+ ADJ_LANES(lane) {
187
+ ADJ_LEAD(lane == 1);
188
+ ADJ_TS(kProf - 3);
189
+ if (lane >= 1 && lane < nb) {
190
+ const int b = lane;
191
+ const S* s = slot[b];
192
+ const S *w = s + 7, *al = s + 10, *ao = s + 13, *wt = s + 16, *vot = s + 19, *al2 = s + 22, *ao2 = s + 25, *wt2 = s + 28,
193
+ *vot2 = s + 31;
194
+ S* o = LV(own);
195
+ for (int k = 0; k < kMsgT; ++k) o[k] = S(0);
196
+ if (xpos_bar) for (int k = 0; k < 3; ++k) { o[k] = xpos_bar[3 * b + k]; o[3 + k] = xrot_bar[3 * b + k]; }
197
+ const S m = B.mass(b);
198
+ S rc[3], I[9], xq2[4], X[9];
199
+ mat_vec(LV(R), B.ipos(b), rc);
200
+ quat_mul(pose ? pose_xquat(pose, b) : s, B.iquat(b), xq2);
201
+ quat_to_mat(xq2, X);
202
+ world_inertia(X, B.inertia(b), I);
203
+ S *tau = o + 3, *wb = o + 6, *alb = o + 9, *aob = o + 12, *wtb = o + 15, *vtb = o + 18, *alb2 = o + 21, *aob2 = o + 24,
204
+ *wtb2 = o + 27, *vtb2 = o + 30;
205
+ S rcb[3] = {S(0), S(0), S(0)}, Ib[9], t[3], u[3], ub[3];
206
+ // channel 1: f = m (ao + al x rc + w x (w x rc)), n = I al + w x I w, vc~ = vo~ + w~ x rc; s1 = coef1 (f . vc~ + n . w~)
207
+ {
208
+ S u1[3], u2[3], u3[3], Iw[3], Ial[3], wIw[3], f[3], n[3], vct[3];
209
+ cross3(al, rc, u1); cross3(w, rc, u2); cross3(w, u2, u3);
210
+ for (int k = 0; k < 3; ++k) f[k] = m * (ao[k] + u1[k] + u3[k]);
211
+ mat_vec(I, w, Iw); mat_vec(I, al, Ial); cross3(w, Iw, wIw);
212
+ for (int k = 0; k < 3; ++k) n[k] = Ial[k] + wIw[k];
213
+ cross3(wt, rc, u1);
214
+ for (int k = 0; k < 3; ++k) vct[k] = vot[k] + u1[k];
215
+ S fb[3], nbar[3], vcb[3], acb[3], nxw[3];
216
+ for (int k = 0; k < 3; ++k) { fb[k] = coef1 * vct[k]; nbar[k] = coef1 * wt[k]; vcb[k] = coef1 * f[k];
217
+ wtb[k] = wtb[k] + coef1 * n[k]; acb[k] = m * fb[k]; }
218
+ mat_vec(I, nbar, t); add3(alb, t);
219
+ cross3(nbar, w, nxw);
220
+ cross3(Iw, nbar, t); add3(wb, t);
221
+ mat_vec(I, nxw, t); add3(wb, t);
222
+ for (int i = 0; i < 3; ++i)
223
+ for (int j = 0; j < 3; ++j) Ib[3 * i + j] = nbar[i] * al[j] + nxw[i] * w[j];
224
+ add3(aob, acb);
225
+ cross3(rc, acb, t); add3(alb, t);
226
+ cross3(acb, al, t); add3(rcb, t);
227
+ cross3(w, rc, u); cross3(acb, w, ub);
228
+ cross3(u, acb, t); add3(wb, t);
229
+ cross3(rc, ub, t); add3(wb, t);
230
+ cross3(ub, w, t); add3(rcb, t);
231
+ add3(vtb, vcb);
232
+ cross3(rc, vcb, t); add3(wtb, t);
233
+ cross3(vcb, wt, t); add3(rcb, t);
234
+ }
235
+ // channel 2 (w = 0): f2 = m (ao2 + al2 x rc), n2 = I al2, vc2~ = vo2~ + w2~ x rc; s2 = coef2 (f2 . vc2~ + n2 . w2~)
236
+ {
237
+ S u1[3], f2[3], n2[3], vct2[3];
238
+ cross3(al2, rc, u1);
239
+ for (int k = 0; k < 3; ++k) f2[k] = m * (ao2[k] + u1[k]);
240
+ mat_vec(I, al2, n2);
241
+ cross3(wt2, rc, u1);
242
+ for (int k = 0; k < 3; ++k) vct2[k] = vot2[k] + u1[k];
243
+ S fb[3], nbar[3], vcb[3], acb[3];
244
+ for (int k = 0; k < 3; ++k) { fb[k] = coef2 * vct2[k]; nbar[k] = coef2 * wt2[k]; vcb[k] = coef2 * f2[k];
245
+ wtb2[k] = wtb2[k] + coef2 * n2[k]; acb[k] = m * fb[k]; }
246
+ mat_vec(I, nbar, t); add3(alb2, t);
247
+ for (int i = 0; i < 3; ++i)
248
+ for (int j = 0; j < 3; ++j) Ib[3 * i + j] = Ib[3 * i + j] + nbar[i] * al2[j];
249
+ add3(aob2, acb);
250
+ cross3(rc, acb, t); add3(alb2, t);
251
+ cross3(acb, al2, t); add3(rcb, t);
252
+ add3(vtb2, vcb);
253
+ cross3(rc, vcb, t); add3(wtb2, t);
254
+ cross3(vcb, wt2, t); add3(rcb, t);
255
+ }
256
+ // rotations of the body-attached rc and I (both channels): tau += rc x rc_bar + vee(Ib I - I Ib)
257
+ cross3(rc, rcb, t); add3(tau, t);
258
+ S G[9];
259
+ for (int i = 0; i < 3; ++i)
260
+ for (int j = 0; j < 3; ++j) {
261
+ S s1 = S(0), s2 = S(0);
262
+ for (int k = 0; k < 3; ++k) { s1 = s1 + Ib[3 * i + k] * I[3 * k + j]; s2 = s2 + I[3 * i + k] * Ib[3 * k + j]; }
263
+ G[3 * i + j] = s1 - s2;
264
+ }
265
+ t[0] = G[7] - G[5]; t[1] = G[2] - G[6]; t[2] = G[3] - G[1];
266
+ add3(tau, t);
267
+ }
268
+ ADJ_TS(kProf - 2);
269
+ }
270
+ // ---- A7: leaf-to-root, both channels and the pose pull-back in one message
271
+ for (int d = B.maxdepth(); d >= 1; --d) {
272
+ ADJ_LANES(lane) {
273
+ ADJ_LEAD(LV(dep) == d);
274
+ if (LV(dep) == d) {
275
+ ADJ_TS(7 + 10 * (d - 1));
276
+ const int b = lane, jt = LV(jtl);
277
+ S acc[kMsgT];
278
+ for (int k = 0; k < kMsgT; ++k) acc[k] = LV(own)[k];
279
+ #pragma unroll
280
+ for (int ci = 0; ci < kMaxKids; ++ci) // the children, in increasing index (unrolled: kid[] stays in registers)
281
+ if (ci < LV(nk)) add_row36(acc, slot[LV(kid)[ci]]);
282
+ ADJ_TS(8 + 10 * (d - 1));
283
+ S *xpb = acc, *tau = acc + 3, *wb = acc + 6, *alb = acc + 9, *aob = acc + 12, *wtb = acc + 15, *vtb = acc + 18,
284
+ *alb2 = acc + 21, *aob2 = acc + 24, *wtb2 = acc + 27, *vtb2 = acc + 30;
285
+ const S* s = slot[b];
286
+ S t[3];
287
+ if (jt == kJntFree) {
288
+ const int dd = B.dadr(b);
289
+ const S *w = s + 7, *al = s + 10, *wt = s + 16, *al2 = s + 22, *wt2 = s + 28; // the root's parent is the world (at rest)
290
+ cross3(w, wb, t); add3(tau, t);
291
+ cross3(al, alb, t); add3(tau, t);
292
+ cross3(wt, wtb, t); add3(tau, t);
293
+ cross3(al2, alb2, t); add3(tau, t);
294
+ cross3(wt2, wtb2, t); add3(tau, t);
295
+ mat_tvec(LV(R), wb, t);
296
+ for (int k = 0; k < 3; ++k) v_bar[dd + 3 + k] = v_bar[dd + 3 + k] + t[k];
297
+ mat_tvec(LV(R), tau, t);
298
+ for (int k = 0; k < 3; ++k) { q_bar[dd + k] = q_bar[dd + k] + xpb[k]; q_bar[dd + 3 + k] = q_bar[dd + 3 + k] + t[k]; }
299
+ } else {
300
+ const S* ps = slot[LV(par)]; // the parent's forward values (it overwrites its slot only in the next phase)
301
+ const S *wp = ps + 7, *alp = ps + 10, *wtp = ps + 16, *al2p = ps + 22, *wt2p = ps + 28;
302
+ S out[kMsgT];
303
+ for (int k = 0; k < kMsgT; ++k) out[k] = S(0);
304
+ S rb[3] = {xpb[0], xpb[1], xpb[2]}, u[3], ub[3];
305
+ S *ow = out + 6, *oal = out + 9, *oao = out + 12, *owt = out + 15, *ovt = out + 18, *oal2 = out + 21, *oao2 = out + 24,
306
+ *owt2 = out + 27, *ovt2 = out + 30;
307
+ // channel 1: ao = ao_p + al_p x r + w_p x (w_p x r); vo~ = vo~_p + w~_p x r
308
+ add3(oao, aob);
309
+ cross3(LV(r), aob, t); add3(oal, t);
310
+ cross3(aob, alp, t); add3(rb, t);
311
+ cross3(wp, LV(r), u); cross3(aob, wp, ub);
312
+ cross3(u, aob, t); add3(ow, t);
313
+ cross3(LV(r), ub, t); add3(ow, t);
314
+ cross3(ub, wp, t); add3(rb, t);
315
+ add3(ovt, vtb);
316
+ cross3(LV(r), vtb, t); add3(owt, t);
317
+ cross3(vtb, wtp, t); add3(rb, t);
318
+ // channel 2: ao2 = ao2_p + al2_p x r; vo2~ = vo2~_p + w2~_p x r
319
+ add3(oao2, aob2);
320
+ cross3(LV(r), aob2, t); add3(oal2, t);
321
+ cross3(aob2, al2p, t); add3(rb, t);
322
+ add3(ovt2, vtb2);
323
+ cross3(LV(r), vtb2, t); add3(owt2, t);
324
+ cross3(vtb2, wt2p, t); add3(rb, t);
325
+ add3(ow, wb); add3(oal, alb); add3(owt, wtb); add3(oal2, alb2); add3(owt2, wtb2);
326
+ if (jt == kJntHinge) {
327
+ const int dd = B.dadr(b);
328
+ const S vb = v[dd];
329
+ S ab3[3], sq[3], sqb[3];
330
+ for (int k = 0; k < 3; ++k) {
331
+ sq[k] = LV(a)[k] * vb;
332
+ ab3[k] = vb * wb[k] + acc1[dd] * alb[k] + seed1[dd] * wtb[k] + acc2[dd] * alb2[k] + seed2[dd] * wtb2[k];
333
+ }
334
+ cross3(sq, alb, t); add3(ow, t);
335
+ cross3(alb, wp, sqb);
336
+ for (int k = 0; k < 3; ++k) ab3[k] = ab3[k] + vb * sqb[k];
337
+ v_bar[dd] = v_bar[dd] + dot3(LV(a), wb) + dot3(LV(a), sqb);
338
+ cross3(LV(a), ab3, t); add3(tau, t);
339
+ q_bar[dd] = q_bar[dd] + dot3(LV(a), tau);
340
+ }
341
+ for (int k = 0; k < 3; ++k) out[k] = xpb[k];
342
+ cross3(LV(r), rb, t);
343
+ for (int k = 0; k < 3; ++k) out[3 + k] = tau[k] + t[k];
344
+ store_row36(slot[b], out); // read by the parent in the next phase
345
+ }
346
+ ADJ_TS(10 + 10 * (d - 1));
347
+ }
348
+ }
349
+ }
350
+ ADJ_LANES(lane) {
351
+ ADJ_LEAD(lane == 0);
352
+ ADJ_TS(kProf - 1);
353
+ }
354
+ }
355
+
356
+ } // namespace js::soft::adj