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,132 @@
1
+ """The 14x training path's binding (2026-11-03; board item 4, the GO): the cotangent charts at the autograd Function's
2
+ boundary, the tape window and the Function (forward = engine14.control_step on a tape slot, backward = the adj14_control_step).
3
+
4
+ Charts. The engine's q [n, 40] holds quaternions (the free root's and the two hip balls'); the adjoint's cotangents are in the
5
+ tangent chart [n, 37] (the and jvp14.h's): the root's world translation and body-frame rotation, each ball's body-frame
6
+ rotation, quat <- quat (x) exp(delta / 2) (right-trivialized), translations and hinges additive.
7
+ out a cotangent g of q1 (raw, from the loss) -> the tangent's: delta-bar = 1/2 Im(conj(q1) (x) g_quat) (q1 unit)
8
+ in a tangent cotangent at q -> q's raw cotangent: g_quat = (2 / |q|) q^ (x) (0, delta-bar) (q^ = q / |q|; the engine
9
+ normalizes its input quaternions, so the raw cotangent is tangent to the sphere)
10
+ """
11
+ import pathlib
12
+
13
+ import torch
14
+
15
+ HERE = pathlib.Path(__file__).resolve().parent
16
+ # (3a) was: sys.path.insert(0, str(HERE))
17
+ from diffneusim.engine import engine14 # noqa: E402
18
+
19
+
20
+ class Chart14:
21
+ """The law's coordinate map (soft14's law JSON): raw q index sets and their tangent indices"""
22
+ def __init__(self, law):
23
+ self.nq, self.nv = law["nq"], law["nv"]
24
+ lin_q, lin_t, quats = [], [], []
25
+ for b in law["bodies"][1:]:
26
+ qa, da = b["qadr"], b["dadr"]
27
+ if b["jtype"] == "free":
28
+ lin_q += [qa, qa + 1, qa + 2]; lin_t += [da, da + 1, da + 2]
29
+ quats.append((qa + 3, da + 3))
30
+ elif b["jtype"] == "ball":
31
+ quats.append((qa, da))
32
+ elif b["jtype"] == "hinge" and b.get("master_dadr", -1) < 0:
33
+ lin_q.append(qa); lin_t.append(da)
34
+ self.lin_q, self.lin_t, self.quats = lin_q, lin_t, quats
35
+ assert len(lin_q) + 4 * len(quats) == self.nq and len(lin_t) + 3 * len(quats) == self.nv, "every coordinate is mapped once"
36
+ self._dev = {}
37
+
38
+ def idx(self, device):
39
+ """index tensors on a device (the batched conversions: one gather per block, all quaternions at once)"""
40
+ if device not in self._dev:
41
+ L = lambda x: torch.tensor(x, dtype=torch.long, device=device) # noqa: E731
42
+ self._dev[device] = dict(lq=L(self.lin_q), lt=L(self.lin_t), qq=L([[qa + k for k in range(4)] for qa, _ in self.quats]),
43
+ qt=L([[da + k for k in range(3)] for _, da in self.quats]),
44
+ conj=torch.tensor([1.0, -1.0, -1.0, -1.0], device=device))
45
+ return self._dev[device]
46
+
47
+
48
+ def _qmul(a, b): # [..., 4] wxyz
49
+ w1, x1, y1, z1 = a.unbind(-1); w2, x2, y2, z2 = b.unbind(-1)
50
+ return torch.stack([w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2, w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2,
51
+ w1 * y2 - x1 * z2 + y1 * w2 + z1 * x2, w1 * z2 + x1 * y2 - y1 * x2 + z1 * w2], -1)
52
+
53
+
54
+ def q_cot_to_tangent(C, q1, g):
55
+ """g [n, nq] (the loss's gradient in q1's raw coordinates) -> [n, nv] in q1's tangent chart (all quaternions in one batch)"""
56
+ I = C.idx(g.device)
57
+ out = torch.empty(g.shape[0], C.nv, dtype=g.dtype, device=g.device)
58
+ out[:, I["lt"]] = g[:, I["lq"]]
59
+ r = _qmul(q1[:, I["qq"]] * I["conj"].to(q1.dtype), g[:, I["qq"]]) # [n, nquat, 4]
60
+ out[:, I["qt"]] = 0.5 * r[..., 1:]
61
+ return out
62
+
63
+
64
+ def tangent_cot_to_q(C, q, gt):
65
+ """gt [n, nv] (a cotangent in q's tangent chart) -> [n, nq] in q's raw coordinates (through the engine's normalization; all
66
+ quaternions in one batch)"""
67
+ I = C.idx(gt.device)
68
+ out = torch.empty(gt.shape[0], C.nq, dtype=gt.dtype, device=gt.device)
69
+ out[:, I["lq"]] = gt[:, I["lt"]]
70
+ Q = q[:, I["qq"]] # [n, nquat, 4]
71
+ r = torch.linalg.norm(Q, dim=-1, keepdim=True)
72
+ pure = torch.nn.functional.pad(gt[:, I["qt"]], (1, 0)) # (0, delta-bar)
73
+ out[:, I["qq"]] = (2.0 / r) * _qmul(Q / r, pure)
74
+ return out
75
+
76
+
77
+ class Window14:
78
+ """One BPTT window's tape: H control steps' records (engine14.alloc_tape under tape_plan's 16 GB rule), a slot per forward
79
+ in order; the adjoint's flags OR-ed on the device (no sync per backward) and asserted by check() / reset() at the window's
80
+ end (after the trainer's backward)."""
81
+ def __init__(self, n, horizon, word_bytes=4, device="cuda"):
82
+ self.plan = engine14.tape_plan(n, horizon, word_bytes=word_bytes)
83
+ self.rec = engine14.alloc_tape(self.plan, device)
84
+ self.H, self.t = horizon, 0
85
+ self.flags = torch.zeros(n, dtype=torch.int32, device=device)
86
+
87
+ def next_slot(self):
88
+ assert self.t < self.H, f"the window's {self.H} control steps are used: reset() at the window's start"
89
+ s = self.t
90
+ self.t += 1
91
+ return s
92
+
93
+ def check(self):
94
+ bad = int((self.flags != 0).sum())
95
+ assert bad == 0, (f"the adjoint flagged {bad} worlds (1: a contact slot not reproduced, 2: a limit-row count, 4: a bad "
96
+ f"record): {torch.nonzero(self.flags).flatten()[:8].tolist()}")
97
+
98
+ def reset(self):
99
+ self.check()
100
+ self.t = 0
101
+
102
+
103
+ class Step14(torch.autograd.Function):
104
+ """One engine14 control step on the training path (board item 4). forward: control_step on the window's next tape slot;
105
+ the outputs are copies (the engine reuses its buffers). backward: the composed adjoint (step 4: the rigid adjoint and the
106
+ muscle_adj per substep) from that slot's records, the cotangents converted at the boundary in the binding (q1's raw -> its
107
+ tangent chart; q's tangent -> raw). Gradients reach q, v, lce, a and u; warm carries none.
108
+ q1, v1, lce1, a1, warm1 = Step14.apply(q, v, lce, a, u, warm, eng, win, chart)"""
109
+ @staticmethod
110
+ def forward(ctx, q, v, lce, a, u, warm, eng, win, C):
111
+ slot = win.next_slot()
112
+ o = eng.control_step(q.detach(), v.detach(), warm, lce.detach(), a.detach(), u.detach(), tape=win.rec[slot])
113
+ q1, v1, l1, a1, w1 = (o[k].clone() for k in ("qpos", "qvel", "lce", "a", "warm"))
114
+ ctx.save_for_backward(q.detach(), a.detach(), u.detach(), q1, l1)
115
+ ctx.eng, ctx.win, ctx.slot, ctx.C = eng, win, slot, C
116
+ ctx.mark_non_differentiable(w1)
117
+ return q1, v1, l1, a1, w1
118
+
119
+ @staticmethod
120
+ def backward(ctx, gq1, gv1, gl1, ga1, gw1):
121
+ q, a0, u, q1, l1 = ctx.saved_tensors
122
+ z = lambda ref: torch.zeros_like(ref) # noqa: E731 (the launcher takes zeros, not null, for an absent cotangent)
123
+ g1 = gq1.contiguous() if gq1 is not None else z(q1)
124
+ wv = gv1.contiguous() if gv1 is not None else torch.zeros(q.shape[0], ctx.C.nv, dtype=q.dtype, device=q.device)
125
+ wl = gl1.contiguous() if gl1 is not None else z(l1)
126
+ wa = ga1.contiguous() if ga1 is not None else z(a0)
127
+ gq, vbar, lbar, abar, ubar, flags = ctx.eng.adjoint_mus_raw(ctx.win.rec[ctx.slot], a0, u, l1, q, q1, g1, wv, wl, wa)
128
+ fl = flags[0]
129
+ for k in range(1, flags.shape[0]):
130
+ fl = fl | flags[k]
131
+ ctx.win.flags.bitwise_or_(fl)
132
+ return gq, vbar, lbar, abar, ubar, None, None, None, None
@@ -0,0 +1,89 @@
1
+ """D16 L4: the tape record (core/soft/tape.h) from Python. The layout comes from the C header through the C ABI
2
+ (soft_tape_layout), so there is one source of truth; decode() splits records into fields the way B's reader does.
3
+ Records are float32 words (production) or float64 words (the f64 build): integer fields are stored bitwise, a u32 in a
4
+ float word and the same u32 zero-extended in a double word, so they are read by reinterpreting the words, never by value.
5
+ """
6
+ import ctypes
7
+
8
+ import numpy as np
9
+
10
+ KEYS = ("nq", "nv", "ntri", "maxcon", "maxrows", "hdr", "flags", "min_nu", "reserved", "clamp", "zone", "con", "qpos", "qvel",
11
+ "qacc", "qadv", "LH", "LQ", "words", "n_clamp", "n_zone", "n_con", "npose", "pose", "nmus", "mus")
12
+ FLAGS = dict(overflow=1 << 0, nonconv=1 << 9, singular=1 << 10, warm=1 << 12, stalled=1 << 13, pose=1 << 14, mus=1 << 15)
13
+ CON_NONE = 0xFFFF
14
+ MAXCON, MAXROWS = 64, 192 # the GPU capacities (core/soft/gpu/l2.cuh kMaxCon, kMaxRows)
15
+
16
+
17
+ def layout(lib, nq, nv, maxcon=MAXCON, maxrows=MAXROWS, npose=0, nmus=0):
18
+ """npose > 0: the optional POSE block (the bodies' frames at the substep's input q) after L_Q; nmus > 0: the optional MUS
19
+ block (lce_prev [nmus]) after it. Through soft_tape_layout2 (26 entries: the 24 of soft_tape_layout, then nmus, mus)."""
20
+ # the library's own count and names must equal KEYS (an entry inserted in the C array would otherwise shift every later
21
+ # index silently; the request after d5's crash, 2026-11-02)
22
+ getattr(lib, "soft_tape_layout2_keys").restype = ctypes.c_char_p
23
+ n_lib, k_lib = int(getattr(lib, "soft_tape_layout2_count")()), getattr(lib, "soft_tape_layout2_keys")().decode()
24
+ assert n_lib == len(KEYS) and k_lib == ",".join(KEYS), (n_lib, len(KEYS), k_lib, ",".join(KEYS))
25
+ out = np.zeros(len(KEYS), np.int32)
26
+ lib.soft_tape_layout2(nq, nv, maxcon, maxrows, npose, nmus, out.ctypes.data_as(ctypes.POINTER(ctypes.c_int)))
27
+ return dict(zip(KEYS, (int(x) for x in out)))
28
+
29
+
30
+ def words_u32(rec):
31
+ """the records' words as u32 (the low half of a double word)"""
32
+ r = np.ascontiguousarray(rec)
33
+ if r.dtype == np.float32:
34
+ return r.view(np.uint32)
35
+ assert r.dtype == np.float64
36
+ return (r.view(np.uint64) & np.uint64(0xFFFFFFFF)).astype(np.uint32)
37
+
38
+
39
+ def tri_unpack(packed, n):
40
+ i, j = np.tril_indices(n)
41
+ out = np.zeros(packed.shape[:-1] + (n, n), packed.dtype)
42
+ out[..., i, j] = packed[..., i * (i + 1) // 2 + j]
43
+ return out
44
+
45
+
46
+ def decode(rec, lay):
47
+ """records (..., words) -> dict: ncon, nefc, nlim, niter, flags (+ one bool per FLAGS key), min_nu, clamp (bool, nv),
48
+ zone (bool, maxrows), pair / slot (int, maxcon; -1 past ncon), qpos, qvel, qacc, qacc_adv, L_H, L_Q (lower, nv x nv)"""
49
+ a = np.ascontiguousarray(rec)
50
+ assert a.shape[-1] == lay["words"], (a.shape, lay["words"])
51
+ u = words_u32(a).astype(np.int64)
52
+ if a.dtype == np.float64: # an int word of the f64 record has its high half zero
53
+ hi = a.view(np.uint64) >> np.uint64(32)
54
+ ints = [lay["hdr"], lay["flags"], lay["reserved"]] + list(range(lay["clamp"], lay["qpos"]))
55
+ assert not hi[..., ints].any(), "an integer word of the f64 record has a nonzero high half"
56
+ hdr, flags = u[..., lay["hdr"]], u[..., lay["flags"]]
57
+ out = dict(ncon=hdr & 255, nefc=(hdr >> 8) & 255, nlim=(hdr >> 16) & 255, niter=hdr >> 24, flags=flags,
58
+ reserved=u[..., lay["reserved"]], min_nu=a[..., lay["min_nu"]])
59
+ for k, b in FLAGS.items():
60
+ out[k] = (flags & b) != 0
61
+ nv, nr, nc = lay["nv"], lay["maxrows"], lay["maxcon"]
62
+ bits = lambda w: ((w[..., :, None] >> np.arange(32)) & 1).astype(bool).reshape(w.shape[:-1] + (-1,)) # noqa: E731
63
+ out["clamp"] = bits(u[..., lay["clamp"]:lay["clamp"] + lay["n_clamp"]])[..., :nv]
64
+ out["zone"] = bits(u[..., lay["zone"]:lay["zone"] + lay["n_zone"]])[..., :nr]
65
+ cw = u[..., lay["con"]:lay["con"] + lay["n_con"]]
66
+ e = np.stack([cw & 0xFFFF, cw >> 16], -1).reshape(cw.shape[:-1] + (-1,))[..., :nc]
67
+ past = np.arange(nc) >= out["ncon"][..., None]
68
+ out["con_raw"] = e
69
+ out["pair"], out["slot"] = np.where(past, -1, e & 511), np.where(past, -1, e >> 9)
70
+ for name, key, n in (("qpos", "qpos", lay["nq"]), ("qvel", "qvel", nv), ("qacc", "qacc", nv), ("qacc_adv", "qadv", nv)):
71
+ out[name] = a[..., lay[key]:lay[key] + n]
72
+ out["L_H"] = tri_unpack(a[..., lay["LH"]:lay["LH"] + lay["ntri"]], nv)
73
+ out["L_Q"] = tri_unpack(a[..., lay["LQ"]:lay["LQ"] + lay["ntri"]], nv)
74
+ np_, nm_ = lay["npose"], lay.get("nmus", 0) # (a layout read from an older file has no nmus: 0)
75
+ end_q = lay["pose"] if np_ > 0 else (lay["mus"] if nm_ > 0 else lay["words"])
76
+ pads = [range(lay["qadv"] + nv, lay["LH"]), range(lay["LH"] + lay["ntri"], lay["LQ"]),
77
+ range(lay["LQ"] + lay["ntri"], end_q)]
78
+ if np_ > 0:
79
+ o = lay["pose"]
80
+ out["xpos"] = a[..., o:o + 3 * np_].reshape(a.shape[:-1] + (np_, 3))
81
+ out["xquat"] = a[..., o + 3 * np_:o + 7 * np_].reshape(a.shape[:-1] + (np_, 4))
82
+ pads.append(range(o + 7 * np_, lay["mus"] if nm_ > 0 else lay["words"]))
83
+ if nm_ > 0:
84
+ out["lce_prev"] = a[..., lay["mus"]:lay["mus"] + nm_]
85
+ pads.append(range(lay["mus"] + nm_, lay["words"]))
86
+ assert (out["pose"] == (np_ > 0)).all(), "the flags' POSE bit disagrees with the layout"
87
+ assert (out["mus"] == (nm_ > 0)).all(), "the flags' MUS bit disagrees with the layout"
88
+ out["pad"] = np.concatenate([u[..., list(r)] for r in pads], -1)
89
+ return out
@@ -0,0 +1,163 @@
1
+ """ctypes loader of the CPU engine prototype (x14_cpu.cpp: the GPU engine's own device code on the host through the fiber shim), and its
2
+ prototype gate (ENGINE_UNIFY_PLAN.md phase 2: the 14x control step's time on the Mac against the 10 ms rule, and its agreement with the f64
3
+ oracle).
4
+ python tools/d16_unify/cpu_engine/x14cpu.py --case CASE_DIR --law-npz NPZ [--oracle C1_OUT.npz] [--variant e0|mm] [--rows N] [--steps S]
5
+ [--out OUT.json]
6
+ --oracle: c1_cpu.py's output for the same rows at --steps 1 (its law is the e0 variant): the CPU engine's f64 control step against it."""
7
+ import argparse
8
+ import ctypes
9
+ import importlib.util
10
+ import json
11
+ import pathlib
12
+ import subprocess
13
+ import sys
14
+
15
+ import numpy as np
16
+
17
+ from diffneusim._paths import ROOT as ROOT # (3a) the repo root
18
+ _s = importlib.util.spec_from_file_location("case_tables", ROOT / "engine" / "case_tables.py")
19
+ KG = importlib.util.module_from_spec(_s)
20
+ _s.loader.exec_module(KG)
21
+ NSUB, KFIB = 5, 6
22
+ VP = ctypes.c_void_p
23
+
24
+
25
+ class X14Cpu:
26
+ def __init__(self, lib, case_dir, prec):
27
+ self.L = ctypes.CDLL(str(lib))
28
+ self.L.x14cpu_new.restype = VP
29
+ self.L.x14cpu_run.restype = ctypes.c_double
30
+ self.has_flags = hasattr(self.L, "x14cpu_run_flags") # a library built before 11-11 lacks it (run() still works)
31
+ if self.has_flags:
32
+ self.L.x14cpu_run_flags.restype = ctypes.c_double
33
+ sz = (ctypes.c_int * 6)()
34
+ self.L.x14cpu_sizes(sz)
35
+ self.nq, self.nv, self.nm = sz[0], sz[1], sz[2]
36
+ self.prec, self.ft = prec, (np.float32 if prec == 0 else np.float64)
37
+ C = KG.load_case(case_dir)
38
+ # the law (11-17, M0): a Millard case runs on a Millard build only (build.sh TAG OUT -DD16_X14_MILLARD exports x14cpu_millard),
39
+ # a Geyer case on a Geyer build only; the Millard case's eleven arrays follow the perm, in case_tables.MILLARD's order (the build's a[52 ..])
40
+ self.millard = KG.is_millard(C)
41
+ assert self.millard == hasattr(self.L, "x14cpu_millard"), (
42
+ f"{lib} is a {'Millard' if hasattr(self.L, 'x14cpu_millard') else 'Geyer'} build and {case_dir} a "
43
+ f"{'Millard' if self.millard else 'Geyer'} case: build the CPU engine with -DD16_X14_MILLARD for a Millard case, without it otherwise")
44
+ if "perm" not in C:
45
+ C["perm"] = np.arange(self.nm, dtype=np.int32)
46
+ self.keep = [np.ascontiguousarray(C[k], dtype=self.ft if (k in KG.FLOATS or C[k].dtype.kind == "f") else np.int32)
47
+ for k in KG.TABLE + ["perm"]]
48
+ assert len(self.keep) == 44, len(self.keep)
49
+ self.keep += [np.ascontiguousarray(C[k], dtype=self.ft if C[k].dtype.kind == "f" else np.int32) for k in KG.law_names(C)]
50
+ assert len(self.keep) == (55 if self.millard else 44), len(self.keep)
51
+ tabs = (VP * len(self.keep))(*[a.ctypes.data for a in self.keep])
52
+ self.dims = np.array(KG.bind_dims(C), np.int32)
53
+ self.h = VP(self.L.x14cpu_new(prec, self.dims.ctypes.data_as(ctypes.POINTER(ctypes.c_int)), tabs))
54
+
55
+ def run(self, q, v, w, lce, a, u, steps=1, nsub=NSUB):
56
+ """steps control steps of nsub substeps (2 ms each), u held; n worlds in rows, run together as the binding's grid. Returns (q, v, warm,
57
+ lce, a), stats [n, steps, nsub, 6] (tail14's rows: ncon, nefc, niter, warm kept, nlim, cap), wall seconds"""
58
+ n = q.shape[0]
59
+ ins = [np.ascontiguousarray(x, dtype=self.ft) for x in (q, v, w, lce, a, u)]
60
+ outs = [np.zeros((n, self.nq), self.ft), np.zeros((n, self.nv), self.ft), np.zeros((n, self.nv), self.ft),
61
+ np.zeros((n, self.nm), self.ft), np.zeros((n, self.nm), self.ft)]
62
+ st = np.zeros((n, steps, nsub, 6), np.int32)
63
+ secs = self.L.x14cpu_run(self.prec, self.h, n, *[x.ctypes.data_as(VP) for x in ins], nsub, KFIB, steps,
64
+ *[x.ctypes.data_as(VP) for x in outs], st.ctypes.data_as(ctypes.POINTER(ctypes.c_int)))
65
+ return outs, st, secs
66
+
67
+ def run_flags(self, q, v, w, lce, a, u, steps=1, nsub=NSUB):
68
+ """run() plus the engine's flag word per world (tail14's, as the binding's flags: kFlagOverflow 1, kFlagCap 4, kFlagRankLoss,
69
+ kFlagHandOrder, kFlagHandOverflow 256), OR-ed over the steps: returns (outs, stats, wall seconds, flags uint32 [n])"""
70
+ assert self.has_flags, "this CPU engine library predates x14cpu_run_flags (11-11): rebuild it with build.sh"
71
+ n = q.shape[0]
72
+ ins = [np.ascontiguousarray(x, dtype=self.ft) for x in (q, v, w, lce, a, u)]
73
+ outs = [np.zeros((n, self.nq), self.ft), np.zeros((n, self.nv), self.ft), np.zeros((n, self.nv), self.ft),
74
+ np.zeros((n, self.nm), self.ft), np.zeros((n, self.nm), self.ft)]
75
+ st = np.zeros((n, steps, nsub, 6), np.int32)
76
+ fl = np.zeros(n, np.uint32)
77
+ secs = self.L.x14cpu_run_flags(self.prec, self.h, n, *[x.ctypes.data_as(VP) for x in ins], nsub, KFIB, steps,
78
+ *[x.ctypes.data_as(VP) for x in outs], st.ctypes.data_as(ctypes.POINTER(ctypes.c_int)),
79
+ fl.ctypes.data_as(VP))
80
+ return outs, st, secs, fl
81
+
82
+ def act(self, u, a_prev, dt=0.002):
83
+ """k_act14: the engine's activation alone (k_mus's first stage), [n, nm] -> [n, nm]"""
84
+ u, a_prev = (np.ascontiguousarray(x, dtype=self.ft) for x in (u, a_prev))
85
+ out = np.zeros_like(a_prev)
86
+ self.L.x14cpu_act(self.prec, self.h, u.shape[0], u.ctypes.data_as(VP), a_prev.ctypes.data_as(VP), ctypes.c_double(dt), out.ctypes.data_as(VP))
87
+ return out
88
+
89
+ def act_vjp(self, u, a_prev, a_bar, dt=0.002):
90
+ """k_act14_vjp: (u_bar, a_prev_bar) for a cotangent a_bar of k_act14's output"""
91
+ u, a_prev, a_bar = (np.ascontiguousarray(x, dtype=self.ft) for x in (u, a_prev, a_bar))
92
+ ub, ab = np.zeros_like(u), np.zeros_like(u)
93
+ self.L.x14cpu_act_vjp(self.prec, self.h, u.shape[0], u.ctypes.data_as(VP), a_prev.ctypes.data_as(VP), ctypes.c_double(dt),
94
+ a_bar.ctypes.data_as(VP), ub.ctypes.data_as(VP), ab.ctypes.data_as(VP))
95
+ return ub, ab
96
+
97
+ def step_rec(self, q, v, w, lce, a, u, nsub=NSUB):
98
+ """one control step with the substeps' activations recorded: (q, v, warm, lce, a), rec_a [nsub, n, nm]"""
99
+ n = q.shape[0]
100
+ ins = [np.ascontiguousarray(x, dtype=self.ft) for x in (q, v, w, lce, a, u)]
101
+ outs = [np.zeros((n, self.nq), self.ft), np.zeros((n, self.nv), self.ft), np.zeros((n, self.nv), self.ft),
102
+ np.zeros((n, self.nm), self.ft), np.zeros((n, self.nm), self.ft)]
103
+ rec = np.zeros((nsub, n, self.nm), self.ft)
104
+ self.L.x14cpu_step_rec.restype = ctypes.c_double
105
+ self.L.x14cpu_step_rec(self.prec, self.h, n, *[x.ctypes.data_as(VP) for x in ins], nsub, KFIB, *[x.ctypes.data_as(VP) for x in outs],
106
+ rec.ctypes.data_as(VP))
107
+ return outs, rec
108
+
109
+ def equil(self, q, lce, a0, outer=8, dt=0.002):
110
+ """k_mus_equil: the fibres' isometric equilibrium at fixed q and a0 (engine14.equil_lce's Geyer path: outer rounds of KFIB Newton steps)"""
111
+ ins = [np.ascontiguousarray(x, dtype=self.ft) for x in (q, lce, a0)]
112
+ out = np.zeros_like(ins[1])
113
+ self.L.x14cpu_equil(self.prec, self.h, q.shape[0], *[x.ctypes.data_as(VP) for x in ins], KFIB, int(outer), ctypes.c_double(dt),
114
+ out.ctypes.data_as(VP))
115
+ return out
116
+
117
+
118
+ def rel(x, ref):
119
+ return float(np.max(np.abs(x - ref) / np.maximum(1.0, np.abs(ref))))
120
+
121
+
122
+ def main():
123
+ ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
124
+ ap.add_argument("--case", required=True)
125
+ ap.add_argument("--law-npz", required=True)
126
+ ap.add_argument("--oracle")
127
+ ap.add_argument("--variant", choices=("e0", "mm"), default="e0")
128
+ ap.add_argument("--rows", type=int, default=40)
129
+ ap.add_argument("--steps", type=int, default=20)
130
+ ap.add_argument("--build-dir", required=True)
131
+ ap.add_argument("--out")
132
+ a = ap.parse_args()
133
+ lib = subprocess.run([str(ROOT / "core" / "cpu_engine" / "build.sh"), a.variant, a.build_dir], check=True, capture_output=True,
134
+ text=True).stdout.strip().splitlines()[-1]
135
+ z = np.load(a.law_npz)
136
+ m = a.rows
137
+ st = dict(q=z["q"][:m], v=z["qd_law"][:m], w=z["warm"][:m], lce=z["lce"][:m], a=z["a"][:m], u=z["u"][:m])
138
+ res = dict(variant=a.variant, lib=lib, rows=m, steps=a.steps, nsub=NSUB, kfib=KFIB)
139
+ for prec, name in ((1, "f64"), (0, "f32")):
140
+ E = X14Cpu(lib, a.case, prec)
141
+ (q1, v1, w1, l1, a1), s1, _ = E.run(st["q"], st["v"], st["w"], st["lce"], st["a"], st["u"], steps=1)
142
+ (q2, v2, _, l2, _), _, _ = E.run(st["q"], st["v"], st["w"], st["lce"], st["a"], st["u"], steps=1)
143
+ det = bool(np.array_equal(q1, q2) and np.array_equal(v1, v2) and np.array_equal(l1, l2))
144
+ fin = bool(all(np.isfinite(x).all() for x in (q1, v1, w1, l1, a1)))
145
+ (qT, vT, _, lT, _), sT, secs = E.run(st["q"], st["v"], st["w"], st["lce"], st["a"], st["u"], steps=a.steps)
146
+ r = dict(deterministic=det, finite_1step=fin, finite_run=bool(np.isfinite(qT).all() and np.isfinite(lT).all()),
147
+ seconds=round(secs, 4), ms_per_control_step=round(1e3 * secs / (m * a.steps), 3),
148
+ niter_hist=np.bincount(sT[..., 2].ravel(), minlength=5).tolist(), nefc_max=int(sT[..., 1].max()),
149
+ big_path_substeps=int((sT[..., 1] > 128).sum()), root_z_range=[round(float(qT[:, 2].min()), 3), round(float(qT[:, 2].max()), 3)])
150
+ if a.oracle and prec == 1:
151
+ o = np.load(a.oracle)
152
+ k = o["q"].shape[0]
153
+ assert k <= m and json.loads(str(o["meta"]))["steps"] == 1, "the oracle: c1_cpu --steps 1 on the first rows"
154
+ r["vs_oracle_1step"] = dict(rows=k, q=rel(q1[:k], o["q"]), v=rel(v1[:k], o["v"]), lce=rel(l1[:k], o["lce"]), a=rel(a1[:k], o["a"]),
155
+ warm=rel(w1[:k], o["warm"]))
156
+ res[name] = r
157
+ print(name, json.dumps(r), flush=True)
158
+ if a.out:
159
+ pathlib.Path(a.out).write_text(json.dumps(res, indent=1))
160
+
161
+
162
+ if __name__ == "__main__":
163
+ sys.exit(main())
File without changes
@@ -0,0 +1,20 @@
1
+ """The handles the environment kept for the development tree's earlier CUDA engine, which is not part of DiffNeuSim. Every run steps the
2
+ engine env14 installs (E0_ENGINE14=1): its step, activation and fibre equilibrium replace these handles at install, and the walking tasks
3
+ assert at run time that nothing reaches them (E0_ENV14_NO_OLD=1). An Absent keeps the plain attributes it is given (the model path) and
4
+ stops any call with an error naming it, so a setting that would need the earlier engine fails at once instead of running something else."""
5
+
6
+
7
+ class Absent:
8
+ def __init__(self, what, **attrs):
9
+ self._what = what
10
+ self.__dict__.update(attrs)
11
+
12
+ def __getattr__(self, name):
13
+ if name.startswith("__"):
14
+ raise AttributeError(name)
15
+ what = self._what
16
+
17
+ def absent(*a, **kw):
18
+ raise AssertionError(f"{what}.{name}: the earlier engine is not part of DiffNeuSim; every run steps the engine env14 installs "
19
+ "(E0_ENGINE14=1), so a setting that reaches this has no engine to run on")
20
+ return absent
@@ -0,0 +1,105 @@
1
+ """env14's CPU backend (feat/d16-taskwalk step 5, the Mac dry-run; E0_ENV14_BACKEND=cpu): Engine14's interface on the CPU engine
2
+ (tools/d16_unify/cpu_engine: the GPU binding's own kernels, x14_engine_kernels.cuh, through the fiber shim). Forward only: there is no CPU
3
+ adjoint, so env14 refuses a gradient-enabled step on it. The engine's dtype is the env's tensors' (float32 by default) and its device the
4
+ CPU. E0_ENV14_CPU_LIB names the built library (tools/d16_unify/cpu_engine/build.sh TAG DIR; the body's tag must match D16_BODY)."""
5
+ import importlib.util
6
+
7
+ import numpy as np
8
+ import torch
9
+
10
+ from diffneusim._paths import ROOT as _ROOT # (3a) the repo root
11
+ _s = importlib.util.spec_from_file_location("x14cpu", _ROOT / "engine" / "x14cpu.py")
12
+ X = importlib.util.module_from_spec(_s)
13
+ _s.loader.exec_module(X)
14
+ # engine14.EQUIL_DT_MILLARD, EQUIL_POLISH_MILLARD (the review's decision (a), 11-05; MILLARD14.md gate 6), written out here because engine14 loads the
15
+ # CUDA extension at import; tools/millard_m0/cpu_millard_gate.py asserts they equal engine14's
16
+ EQUIL_DT_MILLARD, EQUIL_POLISH_MILLARD = (0.1, 2.0), 4
17
+
18
+
19
+ class CpuExt:
20
+ """the binding's act / act_vjp signatures (lists of [n, NM] tensors, in place)"""
21
+
22
+ def __init__(self, E):
23
+ self.E = E
24
+
25
+ def act(self, b, dt):
26
+ b[2].copy_(torch.from_numpy(self.E.act(b[0].numpy(), b[1].numpy(), dt)))
27
+
28
+ def act_vjp(self, b, dt):
29
+ ub, ab = self.E.act_vjp(b[0].numpy(), b[1].numpy(), b[2].numpy(), dt)
30
+ b[3].copy_(torch.from_numpy(ub))
31
+ b[4].copy_(torch.from_numpy(ab))
32
+
33
+
34
+ class CpuEngine14:
35
+ def __init__(self, n, dtype, case_dir, lib):
36
+ self.E = X.X14Cpu(lib, case_dir, 1 if dtype == torch.float64 else 0)
37
+ assert self.E.has_flags, f"{lib} predates the flag word (x14cpu_run_flags, 11-11): rebuild the CPU engine with build.sh"
38
+ self.case = X.KG.load_case(case_dir)
39
+ # a Millard case (11-17, M0) runs on a Millard build of the CPU engine (X14Cpu asserts the pairing); its reset is engine14's
40
+ # Millard schedule, so X14_EQUIL_SCHEDULE (the Geyer-root arm) is refused here as engine14 refuses it
41
+ self.millard, self.equil_schedule, self.equil_log, self.equil_kfib = X.KG.is_millard(self.case), None, [], X.KFIB
42
+ assert self.millard == self.E.millard
43
+ import os
44
+ # X14_MILLARD_EQUIL_SCHEDULE (2026-11-18; engine14's option, OFF by default): a Millard case's reset as these launches instead of
45
+ # the Millard schedule, mirrored here so a CPU dry run follows the same reset (at the CPU engine's own precision)
46
+ msch = os.environ.get("X14_MILLARD_EQUIL_SCHEDULE", "")
47
+ self.millard_schedule = [(int(r), float(d)) for r, d in (x.split(":") for x in msch.split(","))] if msch else None
48
+ assert self.millard_schedule is None or (self.millard and all(r >= 1 and d > 0 for r, d in self.millard_schedule)), \
49
+ f"X14_MILLARD_EQUIL_SCHEDULE={msch!r}: Millard cases only, rounds >= 1, dt > 0 (engine14)"
50
+ self.n, self.dt = n, dtype
51
+ self.ext = CpuExt(self.E)
52
+ self.calls = dict(control_step=0, equil=0)
53
+ # the engine's flag word per world, as engine14's i["flags"]: OR-ed over every control step since zero_flags() (the CPU engine
54
+ # runs the binding's tail14, so the bits are the binding's: kFlagOverflow 1, kFlagCap 4, kFlagHandOverflow 256, ...)
55
+ self.i = dict(flags=torch.zeros(n, dtype=torch.int32))
56
+
57
+ def control_step(self, q, v, warm, lce, a, u, record=False, parts=15, tape=None):
58
+ assert not record and tape is None, "the CPU backend is untaped (forward only)"
59
+ assert not torch.is_grad_enabled(), "the CPU backend has no adjoint: run the dry-run under no_grad"
60
+ outs, stats, _, fl = self.E.run_flags(*(x.detach().numpy() for x in (q, v, warm, lce, a, u)))
61
+ self.calls["control_step"] += 1
62
+ assert fl.max(initial=0) < 2 ** 31, "a flag bit above the int32 word"
63
+ self.i["flags"] |= torch.from_numpy(fl.astype(np.int32))
64
+ t = [torch.from_numpy(x).to(self.dt) for x in outs]
65
+ return dict(qpos=t[0], qvel=t[1], warm=t[2], lce=t[3], a=t[4], stats=torch.from_numpy(stats[:, 0]), flags=self.i["flags"])
66
+
67
+ def zero_flags(self):
68
+ self.i["flags"].zero_()
69
+
70
+ def equil_lce(self, q, lce, a0, mask, outer=8, out=None):
71
+ assert bool(mask.all()), "the CPU backend equilibrates every world"
72
+ if self.millard and self.millard_schedule is not None: # engine14's X14_MILLARD_EQUIL_SCHEDULE: its launches, the first from the seed
73
+ assert int(outer) == 8, f"X14_MILLARD_EQUIL_SCHEDULE with outer {outer}: the schedule sets the rounds"
74
+ r = lce.numpy()
75
+ for k, d in self.millard_schedule:
76
+ r = self.E.equil(q.numpy(), r, a0.numpy(), int(k), dt=d)
77
+ r = torch.from_numpy(r).to(self.dt)
78
+ if not self.equil_log:
79
+ self.equil_log.extend(self.millard_schedule)
80
+ self.calls["equil"] += 1
81
+ if out is None:
82
+ return r
83
+ out.copy_(r)
84
+ return out
85
+ if self.millard: # engine14.equil_lce's Millard path: `outer` rounds at EQUIL_DT_MILLARD[0], then EQUIL_POLISH_MILLARD in place at [1]
86
+ r0 = self.E.equil(q.numpy(), lce.numpy(), a0.numpy(), int(outer), dt=EQUIL_DT_MILLARD[0])
87
+ r = torch.from_numpy(self.E.equil(q.numpy(), r0, a0.numpy(), EQUIL_POLISH_MILLARD, dt=EQUIL_DT_MILLARD[1])).to(self.dt)
88
+ if len(self.equil_log) < 2:
89
+ self.equil_log += [(int(outer), EQUIL_DT_MILLARD[0]), (EQUIL_POLISH_MILLARD, EQUIL_DT_MILLARD[1])]
90
+ self.calls["equil"] += 1
91
+ if out is None:
92
+ return r
93
+ out.copy_(r)
94
+ return out
95
+ r = torch.from_numpy(self.E.equil(q.numpy(), lce.numpy(), a0.numpy(), int(outer))).to(self.dt)
96
+ if len(self.equil_log) < 2:
97
+ self.equil_log.append((int(outer), 0.002))
98
+ self.calls["equil"] += 1
99
+ if out is None:
100
+ return r
101
+ out.copy_(r)
102
+ return out
103
+
104
+ def equil_residual(self, q, lce, a0, mask):
105
+ return (torch.from_numpy(self.E.equil(q.numpy(), lce.numpy(), a0.numpy(), 1)).to(self.dt) - lce).abs()