warp-lang 1.5.0__py3-none-macosx_10_13_universal2.whl → 1.6.0__py3-none-macosx_10_13_universal2.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 (132) hide show
  1. warp/__init__.py +5 -0
  2. warp/autograd.py +414 -191
  3. warp/bin/libwarp-clang.dylib +0 -0
  4. warp/bin/libwarp.dylib +0 -0
  5. warp/build.py +40 -12
  6. warp/build_dll.py +13 -6
  7. warp/builtins.py +1124 -497
  8. warp/codegen.py +261 -136
  9. warp/config.py +1 -1
  10. warp/context.py +357 -119
  11. warp/examples/assets/square_cloth.usd +0 -0
  12. warp/examples/benchmarks/benchmark_gemm.py +27 -18
  13. warp/examples/benchmarks/benchmark_interop_paddle.py +3 -3
  14. warp/examples/benchmarks/benchmark_interop_torch.py +3 -3
  15. warp/examples/core/example_torch.py +18 -34
  16. warp/examples/fem/example_apic_fluid.py +1 -0
  17. warp/examples/fem/example_mixed_elasticity.py +1 -1
  18. warp/examples/optim/example_bounce.py +1 -1
  19. warp/examples/optim/example_cloth_throw.py +1 -1
  20. warp/examples/optim/example_diffray.py +4 -15
  21. warp/examples/optim/example_drone.py +1 -1
  22. warp/examples/optim/example_softbody_properties.py +392 -0
  23. warp/examples/optim/example_trajectory.py +1 -3
  24. warp/examples/optim/example_walker.py +5 -0
  25. warp/examples/sim/example_cartpole.py +0 -2
  26. warp/examples/sim/example_cloth.py +3 -1
  27. warp/examples/sim/example_cloth_self_contact.py +260 -0
  28. warp/examples/sim/example_granular_collision_sdf.py +4 -5
  29. warp/examples/sim/example_jacobian_ik.py +0 -2
  30. warp/examples/sim/example_quadruped.py +5 -2
  31. warp/examples/tile/example_tile_cholesky.py +79 -0
  32. warp/examples/tile/example_tile_convolution.py +2 -2
  33. warp/examples/tile/example_tile_fft.py +2 -2
  34. warp/examples/tile/example_tile_filtering.py +3 -3
  35. warp/examples/tile/example_tile_matmul.py +4 -4
  36. warp/examples/tile/example_tile_mlp.py +12 -12
  37. warp/examples/tile/example_tile_nbody.py +180 -0
  38. warp/examples/tile/example_tile_walker.py +319 -0
  39. warp/fem/geometry/geometry.py +0 -2
  40. warp/math.py +147 -0
  41. warp/native/array.h +12 -0
  42. warp/native/builtin.h +0 -1
  43. warp/native/bvh.cpp +149 -70
  44. warp/native/bvh.cu +287 -68
  45. warp/native/bvh.h +195 -85
  46. warp/native/clang/clang.cpp +5 -1
  47. warp/native/coloring.cpp +5 -1
  48. warp/native/cuda_util.cpp +91 -53
  49. warp/native/cuda_util.h +5 -0
  50. warp/native/exports.h +40 -40
  51. warp/native/intersect.h +17 -0
  52. warp/native/mat.h +41 -0
  53. warp/native/mathdx.cpp +19 -0
  54. warp/native/mesh.cpp +25 -8
  55. warp/native/mesh.cu +153 -101
  56. warp/native/mesh.h +482 -403
  57. warp/native/quat.h +40 -0
  58. warp/native/solid_angle.h +7 -0
  59. warp/native/sort.cpp +85 -0
  60. warp/native/sort.cu +34 -0
  61. warp/native/sort.h +3 -1
  62. warp/native/spatial.h +11 -0
  63. warp/native/tile.h +1187 -669
  64. warp/native/tile_reduce.h +8 -6
  65. warp/native/vec.h +41 -0
  66. warp/native/warp.cpp +8 -1
  67. warp/native/warp.cu +263 -40
  68. warp/native/warp.h +19 -5
  69. warp/optim/linear.py +22 -4
  70. warp/render/render_opengl.py +130 -64
  71. warp/sim/__init__.py +6 -1
  72. warp/sim/collide.py +270 -26
  73. warp/sim/import_urdf.py +8 -8
  74. warp/sim/integrator_euler.py +25 -7
  75. warp/sim/integrator_featherstone.py +154 -35
  76. warp/sim/integrator_vbd.py +842 -40
  77. warp/sim/model.py +134 -72
  78. warp/sparse.py +1 -1
  79. warp/stubs.py +265 -132
  80. warp/tape.py +28 -30
  81. warp/tests/aux_test_module_unload.py +15 -0
  82. warp/tests/{test_sim_grad.py → flaky_test_sim_grad.py} +104 -63
  83. warp/tests/test_array.py +74 -0
  84. warp/tests/test_assert.py +242 -0
  85. warp/tests/test_codegen.py +14 -61
  86. warp/tests/test_collision.py +2 -2
  87. warp/tests/test_coloring.py +12 -2
  88. warp/tests/test_examples.py +12 -1
  89. warp/tests/test_func.py +21 -4
  90. warp/tests/test_grad_debug.py +87 -2
  91. warp/tests/test_hash_grid.py +1 -1
  92. warp/tests/test_ipc.py +116 -0
  93. warp/tests/test_lerp.py +13 -87
  94. warp/tests/test_mat.py +138 -167
  95. warp/tests/test_math.py +47 -1
  96. warp/tests/test_matmul.py +17 -16
  97. warp/tests/test_matmul_lite.py +10 -15
  98. warp/tests/test_mesh.py +84 -60
  99. warp/tests/test_mesh_query_aabb.py +165 -0
  100. warp/tests/test_mesh_query_point.py +328 -286
  101. warp/tests/test_mesh_query_ray.py +134 -121
  102. warp/tests/test_mlp.py +2 -2
  103. warp/tests/test_operators.py +43 -0
  104. warp/tests/test_overwrite.py +47 -2
  105. warp/tests/test_quat.py +77 -0
  106. warp/tests/test_reload.py +29 -0
  107. warp/tests/test_sim_grad_bounce_linear.py +204 -0
  108. warp/tests/test_smoothstep.py +17 -83
  109. warp/tests/test_static.py +19 -3
  110. warp/tests/test_tape.py +25 -0
  111. warp/tests/test_tile.py +178 -191
  112. warp/tests/test_tile_load.py +356 -0
  113. warp/tests/test_tile_mathdx.py +61 -8
  114. warp/tests/test_tile_mlp.py +17 -17
  115. warp/tests/test_tile_reduce.py +24 -18
  116. warp/tests/test_tile_shared_memory.py +66 -17
  117. warp/tests/test_tile_view.py +165 -0
  118. warp/tests/test_torch.py +35 -0
  119. warp/tests/test_utils.py +36 -24
  120. warp/tests/test_vec.py +110 -0
  121. warp/tests/unittest_suites.py +29 -4
  122. warp/tests/unittest_utils.py +30 -13
  123. warp/thirdparty/unittest_parallel.py +2 -2
  124. warp/types.py +411 -101
  125. warp/utils.py +10 -7
  126. {warp_lang-1.5.0.dist-info → warp_lang-1.6.0.dist-info}/METADATA +92 -69
  127. {warp_lang-1.5.0.dist-info → warp_lang-1.6.0.dist-info}/RECORD +130 -119
  128. {warp_lang-1.5.0.dist-info → warp_lang-1.6.0.dist-info}/WHEEL +1 -1
  129. warp/examples/benchmarks/benchmark_tile.py +0 -179
  130. warp/native/tile_gemm.h +0 -341
  131. {warp_lang-1.5.0.dist-info → warp_lang-1.6.0.dist-info}/LICENSE.md +0 -0
  132. {warp_lang-1.5.0.dist-info → warp_lang-1.6.0.dist-info}/top_level.txt +0 -0
warp/tests/test_ipc.py ADDED
@@ -0,0 +1,116 @@
1
+ # Copyright (c) 2024 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 multiprocessing as mp
9
+ import unittest
10
+
11
+ import warp as wp
12
+ from warp.tests.unittest_utils import *
13
+
14
+
15
+ def test_ipc_get_memory_handle(test, device):
16
+ if device.is_ipc_supported is False:
17
+ test.skipTest(f"IPC is not supported on {device}")
18
+
19
+ with wp.ScopedMempool(device, False):
20
+ test_array = wp.full(10, value=42.0, dtype=wp.float32, device=device)
21
+ ipc_handle = test_array.ipc_handle()
22
+
23
+ test.assertNotEqual(ipc_handle, bytes(64), "IPC memory handle appears to be invalid")
24
+
25
+
26
+ def test_ipc_get_event_handle(test, device):
27
+ if device.is_ipc_supported is False:
28
+ test.skipTest(f"IPC is not supported on {device}")
29
+
30
+ e1 = wp.Event(device, interprocess=True)
31
+
32
+ ipc_handle = e1.ipc_handle()
33
+
34
+ test.assertNotEqual(ipc_handle, bytes(64), "IPC event handle appears to be invalid")
35
+
36
+
37
+ def test_ipc_event_missing_interprocess_flag(test, device):
38
+ if device.is_ipc_supported is False:
39
+ test.skipTest(f"IPC is not supported on {device}")
40
+
41
+ e1 = wp.Event(device, interprocess=False)
42
+
43
+ try:
44
+ capture = StdOutCapture()
45
+ capture.begin()
46
+ ipc_handle = e1.ipc_handle()
47
+ finally:
48
+ output = capture.end()
49
+
50
+ # Older Windows C runtimes have a bug where stdout sometimes does not get properly flushed.
51
+ if sys.platform != "win32":
52
+ test.assertRegex(output, r"Warp UserWarning: IPC event handle appears to be invalid.")
53
+
54
+
55
+ @wp.kernel
56
+ def multiply_by_two(a: wp.array(dtype=wp.float32)):
57
+ i = wp.tid()
58
+ a[i] = 2.0 * a[i]
59
+
60
+
61
+ def child_task(array_handle, dtype, shape, device, event_handle):
62
+ with wp.ScopedDevice(device):
63
+ ipc_array = wp.from_ipc_handle(array_handle, dtype, shape, device=device)
64
+ ipc_event = wp.event_from_ipc_handle(event_handle, device=device)
65
+ stream = wp.get_stream()
66
+ wp.launch(multiply_by_two, ipc_array.shape, inputs=[ipc_array])
67
+ stream.record_event(ipc_event)
68
+ stream.wait_event(ipc_event)
69
+ wp.synchronize_device()
70
+
71
+
72
+ def test_ipc_multiprocess_write(test, device):
73
+ if device.is_ipc_supported is False:
74
+ test.skipTest(f"IPC is not supported on {device}")
75
+
76
+ stream = wp.get_stream(device)
77
+ e1 = wp.Event(device, interprocess=True)
78
+
79
+ with wp.ScopedMempool(device, False):
80
+ test_array = wp.full(1024, value=42.0, dtype=wp.float32, device=device)
81
+ ipc_handle = test_array.ipc_handle()
82
+
83
+ wp.launch(multiply_by_two, test_array.shape, inputs=[test_array], device=device)
84
+
85
+ ctx = mp.get_context("spawn")
86
+
87
+ process = ctx.Process(
88
+ target=child_task, args=(ipc_handle, test_array.dtype, test_array.shape, str(device), e1.ipc_handle())
89
+ )
90
+
91
+ process.start()
92
+ process.join()
93
+
94
+ assert_np_equal(test_array.numpy(), np.full(test_array.shape, 168.0, dtype=np.float32))
95
+
96
+
97
+ cuda_devices = get_cuda_test_devices()
98
+
99
+
100
+ class TestIpc(unittest.TestCase):
101
+ pass
102
+
103
+
104
+ add_function_test(TestIpc, "test_ipc_get_memory_handle", test_ipc_get_memory_handle, devices=cuda_devices)
105
+ add_function_test(TestIpc, "test_ipc_get_event_handle", test_ipc_get_event_handle, devices=cuda_devices)
106
+ add_function_test(
107
+ TestIpc, "test_ipc_event_missing_interprocess_flag", test_ipc_event_missing_interprocess_flag, devices=cuda_devices
108
+ )
109
+ add_function_test(
110
+ TestIpc, "test_ipc_multiprocess_write", test_ipc_multiprocess_write, devices=cuda_devices, check_output=False
111
+ )
112
+
113
+
114
+ if __name__ == "__main__":
115
+ wp.clear_kernel_cache()
116
+ unittest.main(verbosity=2)
warp/tests/test_lerp.py CHANGED
@@ -31,66 +31,14 @@ class TestData:
31
31
 
32
32
  TEST_DATA = {
33
33
  wp.float32: (
34
- TestData(
35
- a=1.0,
36
- b=5.0,
37
- t=0.75,
38
- expected=4.0,
39
- expected_adj_a=0.25,
40
- expected_adj_b=0.75,
41
- expected_adj_t=4.0,
42
- ),
43
- TestData(
44
- a=-2.0,
45
- b=5.0,
46
- t=0.25,
47
- expected=-0.25,
48
- expected_adj_a=0.75,
49
- expected_adj_b=0.25,
50
- expected_adj_t=7.0,
51
- ),
52
- TestData(
53
- a=1.23,
54
- b=2.34,
55
- t=0.5,
56
- expected=1.785,
57
- expected_adj_a=0.5,
58
- expected_adj_b=0.5,
59
- expected_adj_t=1.11,
60
- ),
61
- ),
62
- wp.vec2: (
63
- TestData(
64
- a=[1, 2],
65
- b=[3, 4],
66
- t=0.5,
67
- expected=[2, 3],
68
- ),
69
- ),
70
- wp.vec3: (
71
- TestData(
72
- a=[1, 2, 3],
73
- b=[3, 4, 5],
74
- t=0.5,
75
- expected=[2, 3, 4],
76
- ),
77
- ),
78
- wp.vec4: (
79
- TestData(
80
- a=[1, 2, 3, 4],
81
- b=[3, 4, 5, 6],
82
- t=0.5,
83
- expected=[2, 3, 4, 5],
84
- ),
85
- ),
86
- wp.mat22: (
87
- TestData(
88
- a=[[1, 2], [2, 1]],
89
- b=[[3, 4], [4, 3]],
90
- t=0.5,
91
- expected=[[2, 3], [3, 2]],
92
- ),
34
+ TestData(a=1.0, b=5.0, t=0.75, expected=4.0, expected_adj_a=0.25, expected_adj_b=0.75, expected_adj_t=4.0),
35
+ TestData(a=-2.0, b=5.0, t=0.25, expected=-0.25, expected_adj_a=0.75, expected_adj_b=0.25, expected_adj_t=7.0),
36
+ TestData(a=1.23, b=2.34, t=0.5, expected=1.785, expected_adj_a=0.5, expected_adj_b=0.5, expected_adj_t=1.11),
93
37
  ),
38
+ wp.vec2: (TestData(a=[1, 2], b=[3, 4], t=0.5, expected=[2, 3]),),
39
+ wp.vec3: (TestData(a=[1, 2, 3], b=[3, 4, 5], t=0.5, expected=[2, 3, 4]),),
40
+ wp.vec4: (TestData(a=[1, 2, 3, 4], b=[3, 4, 5, 6], t=0.5, expected=[2, 3, 4, 5]),),
41
+ wp.mat22: (TestData(a=[[1, 2], [2, 1]], b=[[3, 4], [4, 3]], t=0.5, expected=[[2, 3], [3, 2]]),),
94
42
  wp.mat33: (
95
43
  TestData(
96
44
  a=[[1, 2, 3], [3, 1, 2], [2, 3, 1]],
@@ -107,30 +55,9 @@ TEST_DATA = {
107
55
  expected=[[2, 3, 4, 5], [5, 2, 3, 4], [4, 5, 2, 3], [3, 4, 5, 2]],
108
56
  ),
109
57
  ),
110
- wp.quat: (
111
- TestData(
112
- a=[1, 2, 3, 4],
113
- b=[3, 4, 5, 6],
114
- t=0.5,
115
- expected=[2, 3, 4, 5],
116
- ),
117
- ),
118
- wp.transform: (
119
- TestData(
120
- a=[1, 2, 3, 4, 5, 6, 7],
121
- b=[3, 4, 5, 6, 7, 8, 9],
122
- t=0.5,
123
- expected=[2, 3, 4, 5, 6, 7, 8],
124
- ),
125
- ),
126
- wp.spatial_vector: (
127
- TestData(
128
- a=[1, 2, 3, 4, 5, 6],
129
- b=[3, 4, 5, 6, 7, 8],
130
- t=0.5,
131
- expected=[2, 3, 4, 5, 6, 7],
132
- ),
133
- ),
58
+ wp.quat: (TestData(a=[1, 2, 3, 4], b=[3, 4, 5, 6], t=0.5, expected=[2, 3, 4, 5]),),
59
+ wp.transform: (TestData(a=[1, 2, 3, 4, 5, 6, 7], b=[3, 4, 5, 6, 7, 8, 9], t=0.5, expected=[2, 3, 4, 5, 6, 7, 8]),),
60
+ wp.spatial_vector: (TestData(a=[1, 2, 3, 4, 5, 6], b=[3, 4, 5, 6, 7, 8], t=0.5, expected=[2, 3, 4, 5, 6, 7]),),
134
61
  wp.spatial_matrix: (
135
62
  TestData(
136
63
  a=[
@@ -175,12 +102,12 @@ def test_lerp(test, device):
175
102
 
176
103
  return fn
177
104
 
178
- for data_type in TEST_DATA:
105
+ for data_type, test_data_set in TEST_DATA.items():
179
106
  kernel_fn = make_kernel_fn(data_type)
180
107
  kernel = wp.Kernel(func=kernel_fn, key=f"test_lerp_{data_type.__name__}_kernel")
181
108
 
182
109
  with test.subTest(data_type=data_type):
183
- for test_data in TEST_DATA[data_type]:
110
+ for test_data in test_data_set:
184
111
  a = wp.array([test_data.a], dtype=data_type, device=device, requires_grad=True)
185
112
  b = wp.array([test_data.b], dtype=data_type, device=device, requires_grad=True)
186
113
  t = wp.array([test_data.t], dtype=float, device=device, requires_grad=True)
@@ -188,8 +115,7 @@ def test_lerp(test, device):
188
115
  [0] * wp.types.type_length(data_type), dtype=data_type, device=device, requires_grad=True
189
116
  )
190
117
 
191
- tape = wp.Tape()
192
- with tape:
118
+ with wp.Tape() as tape:
193
119
  wp.launch(kernel, dim=1, inputs=[a, b, t, out], device=device)
194
120
 
195
121
  assert_np_equal(out.numpy(), np.array([test_data.expected]), tol=1e-6)