warp-lang 0.11.0__py3-none-manylinux2014_x86_64.whl → 1.0.0__py3-none-manylinux2014_x86_64.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.

Potentially problematic release.


This version of warp-lang might be problematic. Click here for more details.

Files changed (170) hide show
  1. warp/__init__.py +8 -0
  2. warp/bin/warp-clang.so +0 -0
  3. warp/bin/warp.so +0 -0
  4. warp/build.py +7 -6
  5. warp/build_dll.py +70 -79
  6. warp/builtins.py +10 -6
  7. warp/codegen.py +51 -19
  8. warp/config.py +7 -8
  9. warp/constants.py +3 -0
  10. warp/context.py +948 -245
  11. warp/dlpack.py +198 -113
  12. warp/examples/assets/bunny.usd +0 -0
  13. warp/examples/assets/cartpole.urdf +110 -0
  14. warp/examples/assets/crazyflie.usd +0 -0
  15. warp/examples/assets/cube.usda +42 -0
  16. warp/examples/assets/nv_ant.xml +92 -0
  17. warp/examples/assets/nv_humanoid.xml +183 -0
  18. warp/examples/assets/quadruped.urdf +268 -0
  19. warp/examples/assets/rocks.nvdb +0 -0
  20. warp/examples/assets/rocks.usd +0 -0
  21. warp/examples/assets/sphere.usda +56 -0
  22. warp/examples/assets/torus.usda +105 -0
  23. warp/examples/benchmarks/benchmark_api.py +383 -0
  24. warp/examples/benchmarks/benchmark_cloth.py +279 -0
  25. warp/examples/benchmarks/benchmark_cloth_cupy.py +88 -0
  26. warp/examples/benchmarks/benchmark_cloth_jax.py +100 -0
  27. warp/examples/benchmarks/benchmark_cloth_numba.py +142 -0
  28. warp/examples/benchmarks/benchmark_cloth_numpy.py +77 -0
  29. warp/examples/benchmarks/benchmark_cloth_pytorch.py +86 -0
  30. warp/examples/benchmarks/benchmark_cloth_taichi.py +112 -0
  31. warp/examples/benchmarks/benchmark_cloth_warp.py +146 -0
  32. warp/examples/benchmarks/benchmark_launches.py +295 -0
  33. warp/examples/core/example_dem.py +221 -0
  34. warp/examples/core/example_fluid.py +267 -0
  35. warp/examples/core/example_graph_capture.py +129 -0
  36. warp/examples/core/example_marching_cubes.py +177 -0
  37. warp/examples/core/example_mesh.py +154 -0
  38. warp/examples/core/example_mesh_intersect.py +193 -0
  39. warp/examples/core/example_nvdb.py +169 -0
  40. warp/examples/core/example_raycast.py +89 -0
  41. warp/examples/core/example_raymarch.py +178 -0
  42. warp/examples/core/example_render_opengl.py +141 -0
  43. warp/examples/core/example_sph.py +389 -0
  44. warp/examples/core/example_torch.py +181 -0
  45. warp/examples/core/example_wave.py +249 -0
  46. warp/examples/fem/bsr_utils.py +380 -0
  47. warp/examples/fem/example_apic_fluid.py +391 -0
  48. warp/examples/fem/example_convection_diffusion.py +168 -0
  49. warp/examples/fem/example_convection_diffusion_dg.py +209 -0
  50. warp/examples/fem/example_convection_diffusion_dg0.py +194 -0
  51. warp/examples/fem/example_deformed_geometry.py +159 -0
  52. warp/examples/fem/example_diffusion.py +173 -0
  53. warp/examples/fem/example_diffusion_3d.py +152 -0
  54. warp/examples/fem/example_diffusion_mgpu.py +214 -0
  55. warp/examples/fem/example_mixed_elasticity.py +222 -0
  56. warp/examples/fem/example_navier_stokes.py +243 -0
  57. warp/examples/fem/example_stokes.py +192 -0
  58. warp/examples/fem/example_stokes_transfer.py +249 -0
  59. warp/examples/fem/mesh_utils.py +109 -0
  60. warp/examples/fem/plot_utils.py +287 -0
  61. warp/examples/optim/example_bounce.py +248 -0
  62. warp/examples/optim/example_cloth_throw.py +210 -0
  63. warp/examples/optim/example_diffray.py +535 -0
  64. warp/examples/optim/example_drone.py +850 -0
  65. warp/examples/optim/example_inverse_kinematics.py +169 -0
  66. warp/examples/optim/example_inverse_kinematics_torch.py +170 -0
  67. warp/examples/optim/example_spring_cage.py +234 -0
  68. warp/examples/optim/example_trajectory.py +201 -0
  69. warp/examples/sim/example_cartpole.py +128 -0
  70. warp/examples/sim/example_cloth.py +184 -0
  71. warp/examples/sim/example_granular.py +113 -0
  72. warp/examples/sim/example_granular_collision_sdf.py +185 -0
  73. warp/examples/sim/example_jacobian_ik.py +213 -0
  74. warp/examples/sim/example_particle_chain.py +106 -0
  75. warp/examples/sim/example_quadruped.py +179 -0
  76. warp/examples/sim/example_rigid_chain.py +191 -0
  77. warp/examples/sim/example_rigid_contact.py +176 -0
  78. warp/examples/sim/example_rigid_force.py +126 -0
  79. warp/examples/sim/example_rigid_gyroscopic.py +97 -0
  80. warp/examples/sim/example_rigid_soft_contact.py +124 -0
  81. warp/examples/sim/example_soft_body.py +178 -0
  82. warp/fabric.py +29 -20
  83. warp/fem/cache.py +0 -1
  84. warp/fem/dirichlet.py +0 -2
  85. warp/fem/integrate.py +0 -1
  86. warp/jax.py +45 -0
  87. warp/jax_experimental.py +339 -0
  88. warp/native/builtin.h +12 -0
  89. warp/native/bvh.cu +18 -18
  90. warp/native/clang/clang.cpp +8 -3
  91. warp/native/cuda_util.cpp +94 -5
  92. warp/native/cuda_util.h +35 -6
  93. warp/native/cutlass_gemm.cpp +1 -1
  94. warp/native/cutlass_gemm.cu +4 -1
  95. warp/native/error.cpp +66 -0
  96. warp/native/error.h +27 -0
  97. warp/native/mesh.cu +2 -2
  98. warp/native/reduce.cu +4 -4
  99. warp/native/runlength_encode.cu +2 -2
  100. warp/native/scan.cu +2 -2
  101. warp/native/sparse.cu +0 -1
  102. warp/native/temp_buffer.h +2 -2
  103. warp/native/warp.cpp +95 -60
  104. warp/native/warp.cu +1053 -218
  105. warp/native/warp.h +49 -32
  106. warp/optim/linear.py +33 -16
  107. warp/render/render_opengl.py +202 -101
  108. warp/render/render_usd.py +82 -40
  109. warp/sim/__init__.py +13 -4
  110. warp/sim/articulation.py +4 -5
  111. warp/sim/collide.py +320 -175
  112. warp/sim/import_mjcf.py +25 -30
  113. warp/sim/import_urdf.py +94 -63
  114. warp/sim/import_usd.py +51 -36
  115. warp/sim/inertia.py +3 -2
  116. warp/sim/integrator.py +233 -0
  117. warp/sim/integrator_euler.py +447 -469
  118. warp/sim/integrator_featherstone.py +1991 -0
  119. warp/sim/integrator_xpbd.py +1420 -640
  120. warp/sim/model.py +765 -487
  121. warp/sim/particles.py +2 -1
  122. warp/sim/render.py +35 -13
  123. warp/sim/utils.py +222 -11
  124. warp/stubs.py +8 -0
  125. warp/tape.py +16 -1
  126. warp/tests/aux_test_grad_customs.py +23 -0
  127. warp/tests/test_array.py +190 -1
  128. warp/tests/test_async.py +656 -0
  129. warp/tests/test_bool.py +50 -0
  130. warp/tests/test_dlpack.py +164 -11
  131. warp/tests/test_examples.py +166 -74
  132. warp/tests/test_fem.py +8 -1
  133. warp/tests/test_generics.py +15 -5
  134. warp/tests/test_grad.py +1 -1
  135. warp/tests/test_grad_customs.py +172 -12
  136. warp/tests/test_jax.py +254 -0
  137. warp/tests/test_large.py +29 -6
  138. warp/tests/test_launch.py +25 -0
  139. warp/tests/test_linear_solvers.py +20 -3
  140. warp/tests/test_matmul.py +61 -16
  141. warp/tests/test_matmul_lite.py +13 -13
  142. warp/tests/test_mempool.py +186 -0
  143. warp/tests/test_multigpu.py +3 -0
  144. warp/tests/test_options.py +16 -2
  145. warp/tests/test_peer.py +137 -0
  146. warp/tests/test_print.py +3 -1
  147. warp/tests/test_quat.py +23 -0
  148. warp/tests/test_sim_kinematics.py +97 -0
  149. warp/tests/test_snippet.py +126 -3
  150. warp/tests/test_streams.py +108 -79
  151. warp/tests/test_torch.py +16 -8
  152. warp/tests/test_utils.py +32 -27
  153. warp/tests/test_verify_fp.py +65 -0
  154. warp/tests/test_volume.py +1 -1
  155. warp/tests/unittest_serial.py +2 -0
  156. warp/tests/unittest_suites.py +12 -0
  157. warp/tests/unittest_utils.py +14 -7
  158. warp/thirdparty/unittest_parallel.py +15 -3
  159. warp/torch.py +10 -8
  160. warp/types.py +363 -246
  161. warp/utils.py +143 -19
  162. warp_lang-1.0.0.dist-info/LICENSE.md +126 -0
  163. warp_lang-1.0.0.dist-info/METADATA +394 -0
  164. {warp_lang-0.11.0.dist-info → warp_lang-1.0.0.dist-info}/RECORD +167 -86
  165. warp/sim/optimizer.py +0 -138
  166. warp_lang-0.11.0.dist-info/LICENSE.md +0 -36
  167. warp_lang-0.11.0.dist-info/METADATA +0 -238
  168. /warp/tests/{walkthough_debug.py → walkthrough_debug.py} +0 -0
  169. {warp_lang-0.11.0.dist-info → warp_lang-1.0.0.dist-info}/WHEEL +0 -0
  170. {warp_lang-0.11.0.dist-info → warp_lang-1.0.0.dist-info}/top_level.txt +0 -0
warp/sim/integrator.py ADDED
@@ -0,0 +1,233 @@
1
+ # Copyright (c) 2022 NVIDIA CORPORATION. All rights reserved.
2
+ # NVIDIA CORPORATION and its licensors retain all intellectual property
3
+ # and proprietary rights in and to this software, related documentation
4
+ # and any modifications thereto. Any use, reproduction, disclosure or
5
+ # distribution of this software and related documentation without an express
6
+ # license agreement from NVIDIA CORPORATION is strictly prohibited.
7
+
8
+ import warp as wp
9
+ from .model import Model, State, Control, PARTICLE_FLAG_ACTIVE
10
+
11
+
12
+ @wp.kernel
13
+ def integrate_particles(
14
+ x: wp.array(dtype=wp.vec3),
15
+ v: wp.array(dtype=wp.vec3),
16
+ f: wp.array(dtype=wp.vec3),
17
+ w: wp.array(dtype=float),
18
+ particle_flags: wp.array(dtype=wp.uint32),
19
+ gravity: wp.vec3,
20
+ dt: float,
21
+ v_max: float,
22
+ x_new: wp.array(dtype=wp.vec3),
23
+ v_new: wp.array(dtype=wp.vec3),
24
+ ):
25
+ tid = wp.tid()
26
+ if (particle_flags[tid] & PARTICLE_FLAG_ACTIVE) == 0:
27
+ return
28
+
29
+ x0 = x[tid]
30
+ v0 = v[tid]
31
+ f0 = f[tid]
32
+
33
+ inv_mass = w[tid]
34
+
35
+ # simple semi-implicit Euler. v1 = v0 + a dt, x1 = x0 + v1 dt
36
+ v1 = v0 + (f0 * inv_mass + gravity * wp.step(-inv_mass)) * dt
37
+ # enforce velocity limit to prevent instability
38
+ v1_mag = wp.length(v1)
39
+ if v1_mag > v_max:
40
+ v1 *= v_max / v1_mag
41
+ x1 = x0 + v1 * dt
42
+
43
+ x_new[tid] = x1
44
+ v_new[tid] = v1
45
+
46
+
47
+ @wp.func
48
+ def integrate_rigid_body(
49
+ q: wp.transform,
50
+ qd: wp.spatial_vector,
51
+ f: wp.spatial_vector,
52
+ com: wp.vec3,
53
+ inertia: wp.mat33,
54
+ inv_mass: float,
55
+ inv_inertia: wp.mat33,
56
+ gravity: wp.vec3,
57
+ angular_damping: float,
58
+ dt: float,
59
+ ):
60
+ # unpack transform
61
+ x0 = wp.transform_get_translation(q)
62
+ r0 = wp.transform_get_rotation(q)
63
+
64
+ # unpack spatial twist
65
+ w0 = wp.spatial_top(qd)
66
+ v0 = wp.spatial_bottom(qd)
67
+
68
+ # unpack spatial wrench
69
+ t0 = wp.spatial_top(f)
70
+ f0 = wp.spatial_bottom(f)
71
+
72
+ x_com = x0 + wp.quat_rotate(r0, com)
73
+
74
+ # linear part
75
+ v1 = v0 + (f0 * inv_mass + gravity * wp.nonzero(inv_mass)) * dt
76
+ x1 = x_com + v1 * dt
77
+
78
+ # angular part (compute in body frame)
79
+ wb = wp.quat_rotate_inv(r0, w0)
80
+ tb = wp.quat_rotate_inv(r0, t0) - wp.cross(wb, inertia * wb) # coriolis forces
81
+
82
+ w1 = wp.quat_rotate(r0, wb + inv_inertia * tb * dt)
83
+ r1 = wp.normalize(r0 + wp.quat(w1, 0.0) * r0 * 0.5 * dt)
84
+
85
+ # angular damping
86
+ w1 *= 1.0 - angular_damping * dt
87
+
88
+ q_new = wp.transform(x1 - wp.quat_rotate(r1, com), r1)
89
+ qd_new = wp.spatial_vector(w1, v1)
90
+
91
+ return q_new, qd_new
92
+
93
+
94
+ # semi-implicit Euler integration
95
+ @wp.kernel
96
+ def integrate_bodies(
97
+ body_q: wp.array(dtype=wp.transform),
98
+ body_qd: wp.array(dtype=wp.spatial_vector),
99
+ body_f: wp.array(dtype=wp.spatial_vector),
100
+ body_com: wp.array(dtype=wp.vec3),
101
+ m: wp.array(dtype=float),
102
+ I: wp.array(dtype=wp.mat33),
103
+ inv_m: wp.array(dtype=float),
104
+ inv_I: wp.array(dtype=wp.mat33),
105
+ gravity: wp.vec3,
106
+ angular_damping: float,
107
+ dt: float,
108
+ # outputs
109
+ body_q_new: wp.array(dtype=wp.transform),
110
+ body_qd_new: wp.array(dtype=wp.spatial_vector),
111
+ ):
112
+ tid = wp.tid()
113
+
114
+ # positions
115
+ q = body_q[tid]
116
+ qd = body_qd[tid]
117
+ f = body_f[tid]
118
+
119
+ # masses
120
+ inv_mass = inv_m[tid] # 1 / mass
121
+
122
+ inertia = I[tid]
123
+ inv_inertia = inv_I[tid] # inverse of 3x3 inertia matrix
124
+
125
+ com = body_com[tid]
126
+
127
+ q_new, qd_new = integrate_rigid_body(
128
+ q,
129
+ qd,
130
+ f,
131
+ com,
132
+ inertia,
133
+ inv_mass,
134
+ inv_inertia,
135
+ gravity,
136
+ angular_damping,
137
+ dt,
138
+ )
139
+
140
+ body_q_new[tid] = q_new
141
+ body_qd_new[tid] = qd_new
142
+
143
+
144
+ class Integrator:
145
+ """
146
+ Generic base class for integrators. Provides methods to integrate rigid bodies and particles.
147
+ """
148
+
149
+ def integrate_bodies(
150
+ self,
151
+ model: Model,
152
+ state_in: State,
153
+ state_out: State,
154
+ dt: float,
155
+ angular_damping: float = 0.0,
156
+ ):
157
+ """
158
+ Integrate the rigid bodies of the model.
159
+
160
+ Args:
161
+ model (Model): The model to integrate.
162
+ state_in (State): The input state.
163
+ state_out (State): The output state.
164
+ dt (float): The time step (typically in seconds).
165
+ angular_damping (float, optional): The angular damping factor. Defaults to 0.0.
166
+ """
167
+ if model.body_count:
168
+ wp.launch(
169
+ kernel=integrate_bodies,
170
+ dim=model.body_count,
171
+ inputs=[
172
+ state_in.body_q,
173
+ state_in.body_qd,
174
+ state_in.body_f,
175
+ model.body_com,
176
+ model.body_mass,
177
+ model.body_inertia,
178
+ model.body_inv_mass,
179
+ model.body_inv_inertia,
180
+ model.gravity,
181
+ angular_damping,
182
+ dt,
183
+ ],
184
+ outputs=[state_out.body_q, state_out.body_qd],
185
+ device=model.device,
186
+ )
187
+
188
+ def integrate_particles(
189
+ self,
190
+ model: Model,
191
+ state_in: State,
192
+ state_out: State,
193
+ dt: float,
194
+ ):
195
+ """
196
+ Integrate the particles of the model.
197
+
198
+ Args:
199
+ model (Model): The model to integrate.
200
+ state_in (State): The input state.
201
+ state_out (State): The output state.
202
+ dt (float): The time step (typically in seconds).
203
+ """
204
+ if model.particle_count:
205
+ wp.launch(
206
+ kernel=integrate_particles,
207
+ dim=model.particle_count,
208
+ inputs=[
209
+ state_in.particle_q,
210
+ state_in.particle_qd,
211
+ state_in.particle_f,
212
+ model.particle_inv_mass,
213
+ model.particle_flags,
214
+ model.gravity,
215
+ dt,
216
+ model.particle_max_velocity,
217
+ ],
218
+ outputs=[state_out.particle_q, state_out.particle_qd],
219
+ device=model.device,
220
+ )
221
+
222
+ def simulate(self, model: Model, state_in: State, state_out: State, dt: float, control: Control = None):
223
+ """
224
+ Simulate the model for a given time step using the given control input.
225
+
226
+ Args:
227
+ model (Model): The model to simulate.
228
+ state_in (State): The input state.
229
+ state_out (State): The output state.
230
+ dt (float): The time step (typically in seconds).
231
+ control (Control): The control input. Defaults to `None` which means the control values from the :class:`Model` are used.
232
+ """
233
+ raise NotImplementedError()