warp-lang 0.15.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.
- warp/__init__.py +1 -0
- warp/codegen.py +7 -3
- warp/config.py +2 -1
- warp/constants.py +3 -0
- warp/context.py +44 -21
- warp/examples/assets/bunny.usd +0 -0
- warp/examples/assets/cartpole.urdf +110 -0
- warp/examples/assets/crazyflie.usd +0 -0
- warp/examples/assets/cube.usda +42 -0
- warp/examples/assets/nv_ant.xml +92 -0
- warp/examples/assets/nv_humanoid.xml +183 -0
- warp/examples/assets/quadruped.urdf +268 -0
- warp/examples/assets/rocks.nvdb +0 -0
- warp/examples/assets/rocks.usd +0 -0
- warp/examples/assets/sphere.usda +56 -0
- warp/examples/assets/torus.usda +105 -0
- warp/examples/core/example_dem.py +6 -6
- warp/examples/core/example_fluid.py +3 -3
- warp/examples/core/example_graph_capture.py +3 -6
- warp/examples/optim/example_bounce.py +9 -8
- warp/examples/optim/example_cloth_throw.py +12 -8
- warp/examples/optim/example_diffray.py +10 -12
- warp/examples/optim/example_drone.py +31 -14
- warp/examples/optim/example_spring_cage.py +10 -15
- warp/examples/optim/example_trajectory.py +7 -24
- warp/examples/sim/example_cartpole.py +3 -9
- warp/examples/sim/example_cloth.py +10 -10
- warp/examples/sim/example_granular.py +3 -3
- warp/examples/sim/example_granular_collision_sdf.py +9 -4
- warp/examples/sim/example_jacobian_ik.py +0 -10
- warp/examples/sim/example_particle_chain.py +4 -4
- warp/examples/sim/example_quadruped.py +15 -11
- warp/examples/sim/example_rigid_chain.py +13 -8
- warp/examples/sim/example_rigid_contact.py +4 -4
- warp/examples/sim/example_rigid_force.py +7 -7
- warp/examples/sim/example_rigid_soft_contact.py +4 -4
- warp/examples/sim/example_soft_body.py +3 -3
- warp/jax.py +45 -0
- warp/jax_experimental.py +339 -0
- warp/render/render_opengl.py +188 -95
- warp/render/render_usd.py +34 -10
- warp/sim/__init__.py +13 -4
- warp/sim/articulation.py +4 -5
- warp/sim/collide.py +320 -175
- warp/sim/import_mjcf.py +25 -30
- warp/sim/import_urdf.py +94 -63
- warp/sim/import_usd.py +51 -36
- warp/sim/inertia.py +3 -2
- warp/sim/integrator.py +233 -0
- warp/sim/integrator_euler.py +447 -469
- warp/sim/integrator_featherstone.py +1991 -0
- warp/sim/integrator_xpbd.py +1420 -640
- warp/sim/model.py +741 -487
- warp/sim/particles.py +2 -1
- warp/sim/render.py +18 -2
- warp/sim/utils.py +222 -11
- warp/stubs.py +1 -0
- warp/tape.py +6 -9
- warp/tests/test_examples.py +87 -20
- warp/tests/test_grad_customs.py +122 -0
- warp/tests/test_jax.py +254 -0
- warp/tests/test_options.py +13 -53
- warp/tests/test_quat.py +23 -0
- warp/tests/test_snippet.py +2 -0
- warp/tests/test_utils.py +31 -26
- warp/tests/test_verify_fp.py +65 -0
- warp/tests/unittest_suites.py +4 -0
- warp/utils.py +50 -1
- {warp_lang-0.15.0.dist-info → warp_lang-1.0.0.dist-info}/METADATA +1 -1
- {warp_lang-0.15.0.dist-info → warp_lang-1.0.0.dist-info}/RECORD +73 -64
- warp/examples/env/__init__.py +0 -0
- warp/examples/env/env_ant.py +0 -61
- warp/examples/env/env_cartpole.py +0 -63
- warp/examples/env/env_humanoid.py +0 -65
- warp/examples/env/env_usd.py +0 -97
- warp/examples/env/environment.py +0 -526
- warp/sim/optimizer.py +0 -138
- {warp_lang-0.15.0.dist-info → warp_lang-1.0.0.dist-info}/LICENSE.md +0 -0
- {warp_lang-0.15.0.dist-info → warp_lang-1.0.0.dist-info}/WHEEL +0 -0
- {warp_lang-0.15.0.dist-info → warp_lang-1.0.0.dist-info}/top_level.txt +0 -0
warp/sim/optimizer.py
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
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
|
-
from warp.context import synchronize
|
|
9
|
-
import warp as wp
|
|
10
|
-
|
|
11
|
-
import numpy as np
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@wp.kernel
|
|
15
|
-
def gd_step(arr_x: wp.array(dtype=float), arr_dfdx: wp.array(dtype=float), alpha: float):
|
|
16
|
-
tid = wp.tid()
|
|
17
|
-
|
|
18
|
-
x = arr_x[tid]
|
|
19
|
-
dfdx = arr_dfdx[tid]
|
|
20
|
-
|
|
21
|
-
x = x - dfdx * alpha
|
|
22
|
-
|
|
23
|
-
arr_x[tid] = x
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@wp.kernel
|
|
27
|
-
def nesterov1(beta: float, x: wp.array(dtype=float), x_prev: wp.array(dtype=float), y: wp.array(dtype=float)):
|
|
28
|
-
tid = wp.tid()
|
|
29
|
-
|
|
30
|
-
y[tid] = x[tid] + beta * (x[tid] - x_prev[tid])
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
@wp.kernel
|
|
34
|
-
def nesterov2(
|
|
35
|
-
alpha: float,
|
|
36
|
-
beta: wp.array(dtype=float),
|
|
37
|
-
eta: wp.array(dtype=float),
|
|
38
|
-
x: wp.array(dtype=float),
|
|
39
|
-
x_prev: wp.array(dtype=float),
|
|
40
|
-
y: wp.array(dtype=float),
|
|
41
|
-
dfdx: wp.array(dtype=float),
|
|
42
|
-
):
|
|
43
|
-
# if (eta > 0.0):
|
|
44
|
-
# # adaptive restart
|
|
45
|
-
# x_prev = x
|
|
46
|
-
# b = 0
|
|
47
|
-
# else:
|
|
48
|
-
# # nesterov update
|
|
49
|
-
# x_prev = x
|
|
50
|
-
# x = y - alpha*dfdx
|
|
51
|
-
|
|
52
|
-
tid = wp.tid()
|
|
53
|
-
|
|
54
|
-
x_prev[tid] = x[tid]
|
|
55
|
-
x[tid] = y[tid] - alpha * dfdx[tid]
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def inner(a, b, out):
|
|
59
|
-
from warp.utils import array_inner
|
|
60
|
-
|
|
61
|
-
array_inner(a, b, out)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
class Optimizer:
|
|
65
|
-
def __init__(self, n, mode, device):
|
|
66
|
-
self.n = n
|
|
67
|
-
self.mode = mode
|
|
68
|
-
self.device = device
|
|
69
|
-
|
|
70
|
-
# allocate space for residual buffers
|
|
71
|
-
self.dfdx = wp.zeros(n, dtype=float, device=device)
|
|
72
|
-
|
|
73
|
-
if mode == "nesterov":
|
|
74
|
-
self.x_prev = wp.zeros(n, dtype=float, device=device)
|
|
75
|
-
self.y = wp.zeros(n, dtype=float, device=device)
|
|
76
|
-
self.eta = wp.zeros(1, dtype=float, device=device)
|
|
77
|
-
self.eta_prev = wp.zeros(1, dtype=float, device=device)
|
|
78
|
-
self.beta = wp.zeros(1, dtype=int, device=device)
|
|
79
|
-
|
|
80
|
-
def solve(self, x, grad_func, max_iters=20, alpha=0.01, report=False):
|
|
81
|
-
if report:
|
|
82
|
-
stats = {}
|
|
83
|
-
|
|
84
|
-
# reset stats
|
|
85
|
-
stats["evals"] = 0
|
|
86
|
-
stats["residual"] = []
|
|
87
|
-
|
|
88
|
-
if self.mode == "gd":
|
|
89
|
-
for i in range(max_iters):
|
|
90
|
-
# compute residual
|
|
91
|
-
grad_func(x, self.dfdx)
|
|
92
|
-
|
|
93
|
-
# gradient step
|
|
94
|
-
wp.launch(kernel=gd_step, dim=self.n, inputs=[x, self.dfdx, alpha], device=self.device)
|
|
95
|
-
|
|
96
|
-
if report:
|
|
97
|
-
stats["evals"] += 1
|
|
98
|
-
|
|
99
|
-
r = np.linalg.norm(self.dfdx.to("cpu").numpy())
|
|
100
|
-
stats["residual"].append(r)
|
|
101
|
-
|
|
102
|
-
elif self.mode == "nesterov":
|
|
103
|
-
wp.copy(self.x_prev, x)
|
|
104
|
-
|
|
105
|
-
# momentum index (reset after restart)
|
|
106
|
-
b = 0
|
|
107
|
-
for iter in range(max_iters):
|
|
108
|
-
beta = (b - 1.0) / (b + 2.0)
|
|
109
|
-
b += 1
|
|
110
|
-
|
|
111
|
-
# y = x + beta*(x - x_prev)
|
|
112
|
-
wp.launch(kernel=nesterov1, dim=self.n, inputs=[beta, x, self.x_prev, self.y], device=self.device)
|
|
113
|
-
|
|
114
|
-
# grad
|
|
115
|
-
grad_func(self.y, self.dfdx)
|
|
116
|
-
|
|
117
|
-
# inner()
|
|
118
|
-
# np.dot(dfdx, x - x_prev)
|
|
119
|
-
|
|
120
|
-
# x = y - alpha*dfdx
|
|
121
|
-
wp.launch(
|
|
122
|
-
kernel=nesterov2,
|
|
123
|
-
dim=self.n,
|
|
124
|
-
inputs=[alpha, None, None, x, self.x_prev, self.y, self.dfdx],
|
|
125
|
-
device=self.device,
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
if report:
|
|
129
|
-
stats["evals"] += 1
|
|
130
|
-
|
|
131
|
-
r = np.linalg.norm(self.dfdx.to("cpu").numpy())
|
|
132
|
-
stats["residual"].append(r)
|
|
133
|
-
|
|
134
|
-
else:
|
|
135
|
-
raise RuntimeError("Unknown optimizer")
|
|
136
|
-
|
|
137
|
-
if report:
|
|
138
|
-
print(stats)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|