warp-lang 1.5.1__py3-none-win_amd64.whl → 1.6.1__py3-none-win_amd64.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 (131) hide show
  1. warp/__init__.py +5 -0
  2. warp/autograd.py +414 -191
  3. warp/bin/warp-clang.dll +0 -0
  4. warp/bin/warp.dll +0 -0
  5. warp/build.py +40 -12
  6. warp/build_dll.py +13 -6
  7. warp/builtins.py +1077 -481
  8. warp/codegen.py +250 -122
  9. warp/config.py +65 -21
  10. warp/context.py +500 -149
  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_marching_cubes.py +1 -1
  16. warp/examples/core/example_mesh.py +1 -1
  17. warp/examples/core/example_torch.py +18 -34
  18. warp/examples/core/example_wave.py +1 -1
  19. warp/examples/fem/example_apic_fluid.py +1 -0
  20. warp/examples/fem/example_mixed_elasticity.py +1 -1
  21. warp/examples/optim/example_bounce.py +1 -1
  22. warp/examples/optim/example_cloth_throw.py +1 -1
  23. warp/examples/optim/example_diffray.py +4 -15
  24. warp/examples/optim/example_drone.py +1 -1
  25. warp/examples/optim/example_softbody_properties.py +392 -0
  26. warp/examples/optim/example_trajectory.py +1 -3
  27. warp/examples/optim/example_walker.py +5 -0
  28. warp/examples/sim/example_cartpole.py +0 -2
  29. warp/examples/sim/example_cloth_self_contact.py +314 -0
  30. warp/examples/sim/example_granular_collision_sdf.py +4 -5
  31. warp/examples/sim/example_jacobian_ik.py +0 -2
  32. warp/examples/sim/example_quadruped.py +5 -2
  33. warp/examples/tile/example_tile_cholesky.py +79 -0
  34. warp/examples/tile/example_tile_convolution.py +2 -2
  35. warp/examples/tile/example_tile_fft.py +2 -2
  36. warp/examples/tile/example_tile_filtering.py +3 -3
  37. warp/examples/tile/example_tile_matmul.py +4 -4
  38. warp/examples/tile/example_tile_mlp.py +12 -12
  39. warp/examples/tile/example_tile_nbody.py +191 -0
  40. warp/examples/tile/example_tile_walker.py +319 -0
  41. warp/math.py +147 -0
  42. warp/native/array.h +12 -0
  43. warp/native/builtin.h +0 -1
  44. warp/native/bvh.cpp +149 -70
  45. warp/native/bvh.cu +287 -68
  46. warp/native/bvh.h +195 -85
  47. warp/native/clang/clang.cpp +6 -2
  48. warp/native/crt.h +1 -0
  49. warp/native/cuda_util.cpp +35 -0
  50. warp/native/cuda_util.h +5 -0
  51. warp/native/exports.h +40 -40
  52. warp/native/intersect.h +17 -0
  53. warp/native/mat.h +57 -3
  54. warp/native/mathdx.cpp +19 -0
  55. warp/native/mesh.cpp +25 -8
  56. warp/native/mesh.cu +153 -101
  57. warp/native/mesh.h +482 -403
  58. warp/native/quat.h +40 -0
  59. warp/native/solid_angle.h +7 -0
  60. warp/native/sort.cpp +85 -0
  61. warp/native/sort.cu +34 -0
  62. warp/native/sort.h +3 -1
  63. warp/native/spatial.h +11 -0
  64. warp/native/tile.h +1189 -664
  65. warp/native/tile_reduce.h +8 -6
  66. warp/native/vec.h +41 -0
  67. warp/native/warp.cpp +8 -1
  68. warp/native/warp.cu +263 -40
  69. warp/native/warp.h +19 -5
  70. warp/optim/linear.py +22 -4
  71. warp/render/render_opengl.py +132 -59
  72. warp/render/render_usd.py +10 -2
  73. warp/sim/__init__.py +6 -1
  74. warp/sim/collide.py +289 -32
  75. warp/sim/import_urdf.py +20 -5
  76. warp/sim/integrator_euler.py +25 -7
  77. warp/sim/integrator_featherstone.py +147 -35
  78. warp/sim/integrator_vbd.py +842 -40
  79. warp/sim/model.py +173 -112
  80. warp/sim/render.py +2 -2
  81. warp/stubs.py +249 -116
  82. warp/tape.py +28 -30
  83. warp/tests/aux_test_module_unload.py +15 -0
  84. warp/tests/{test_sim_grad.py → flaky_test_sim_grad.py} +104 -63
  85. warp/tests/test_array.py +100 -0
  86. warp/tests/test_assert.py +242 -0
  87. warp/tests/test_codegen.py +14 -61
  88. warp/tests/test_collision.py +8 -8
  89. warp/tests/test_examples.py +16 -1
  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_launch.py +77 -26
  94. warp/tests/test_mat.py +213 -168
  95. warp/tests/test_math.py +47 -1
  96. warp/tests/test_matmul.py +11 -7
  97. warp/tests/test_matmul_lite.py +4 -4
  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 +6 -5
  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_static.py +16 -0
  109. warp/tests/test_tape.py +25 -0
  110. warp/tests/test_tile.py +134 -191
  111. warp/tests/test_tile_load.py +399 -0
  112. warp/tests/test_tile_mathdx.py +61 -8
  113. warp/tests/test_tile_mlp.py +17 -17
  114. warp/tests/test_tile_reduce.py +24 -18
  115. warp/tests/test_tile_shared_memory.py +66 -17
  116. warp/tests/test_tile_view.py +165 -0
  117. warp/tests/test_torch.py +35 -0
  118. warp/tests/test_utils.py +36 -24
  119. warp/tests/test_vec.py +110 -0
  120. warp/tests/unittest_suites.py +29 -4
  121. warp/tests/unittest_utils.py +30 -11
  122. warp/thirdparty/unittest_parallel.py +5 -2
  123. warp/types.py +419 -111
  124. warp/utils.py +9 -5
  125. {warp_lang-1.5.1.dist-info → warp_lang-1.6.1.dist-info}/METADATA +86 -45
  126. {warp_lang-1.5.1.dist-info → warp_lang-1.6.1.dist-info}/RECORD +129 -118
  127. {warp_lang-1.5.1.dist-info → warp_lang-1.6.1.dist-info}/WHEEL +1 -1
  128. warp/examples/benchmarks/benchmark_tile.py +0 -179
  129. warp/native/tile_gemm.h +0 -341
  130. {warp_lang-1.5.1.dist-info → warp_lang-1.6.1.dist-info}/LICENSE.md +0 -0
  131. {warp_lang-1.5.1.dist-info → warp_lang-1.6.1.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_launch.py CHANGED
@@ -46,6 +46,12 @@ def kernel4d(a: wp.array(dtype=int, ndim=4)):
46
46
  wp.expect_eq(a[i, j, k, l], i * dim_y * dim_z * dim_w + j * dim_z * dim_w + k * dim_w + l)
47
47
 
48
48
 
49
+ @wp.kernel
50
+ def square_kernel(input: wp.array(dtype=float), output: wp.array(dtype=float)):
51
+ i = wp.tid()
52
+ output[i] = input[i] * input[i]
53
+
54
+
49
55
  def test1d(test, device):
50
56
  a = np.arange(0, dim_x).reshape(dim_x)
51
57
 
@@ -98,8 +104,19 @@ def kernel_cmd(params: Params, i: int, f: float, v: wp.vec3, m: wp.mat33, out: w
98
104
 
99
105
 
100
106
  def test_launch_cmd(test, device):
107
+ """Tests recording and executing a kernel launch command.
108
+
109
+ Verifies that:
110
+ - A kernel can be recorded as a command without immediate execution
111
+ - The recorded command can be launched later
112
+ - Parameters are correctly passed to the kernel
113
+ - Output matches expected results for both immediate and delayed launches
114
+
115
+ Args:
116
+ test: Test context
117
+ device: Device to run the test on
118
+ """
101
119
  n = 1
102
-
103
120
  ref = np.arange(0, n)
104
121
  out = wp.zeros(n, dtype=int, device=device)
105
122
 
@@ -274,12 +291,62 @@ def test_launch_cmd_empty(test, device):
274
291
  assert_np_equal(out.numpy(), ref)
275
292
 
276
293
 
294
+ def test_launch_cmd_adjoint(test, device):
295
+ """Test recording an adjoint launch with record_cmd=True."""
296
+ input_arr = wp.array([1.0, 2.0, 3.0], dtype=float, requires_grad=True, device=device)
297
+ output_arr = wp.empty_like(input_arr)
298
+
299
+ output_arr.grad.fill_(1.0)
300
+
301
+ cmd = wp.launch(
302
+ square_kernel,
303
+ dim=input_arr.size,
304
+ inputs=[input_arr, output_arr],
305
+ adj_inputs=[None, None],
306
+ adjoint=True,
307
+ device=device,
308
+ record_cmd=True,
309
+ )
310
+
311
+ cmd.launch()
312
+
313
+ assert_np_equal(input_arr.grad.numpy(), np.array([2.0, 4.0, 6.0]))
314
+
315
+
316
+ def test_launch_cmd_adjoint_empty(test, device):
317
+ """Test constructing a Launch object for an adjoint kernel."""
318
+ input_arr = wp.array([1.0, 2.0, 3.0], dtype=float, requires_grad=True, device=device)
319
+ output_arr = wp.empty_like(input_arr)
320
+ output_arr.grad.fill_(1.0)
321
+
322
+ cmd = wp.Launch(square_kernel, device, adjoint=True)
323
+ cmd.set_param_by_name("input", input_arr)
324
+ cmd.set_param_by_name("output", output_arr)
325
+ cmd.set_dim(input_arr.size)
326
+ cmd.launch()
327
+
328
+ assert_np_equal(input_arr.grad.numpy(), np.array([2.0, 4.0, 6.0]))
329
+
330
+ # Now update the launch object's parameters with arrays of different sizes and values
331
+ # and check that the adjoints are correctly computed
332
+ input_arr_updated = wp.array([4.0, 5.0, 6.0, 7.0], dtype=float, device=device)
333
+ input_arr_updated_grad = wp.zeros_like(input_arr_updated)
334
+
335
+ output_arr_updated = wp.empty_like(input_arr_updated)
336
+ output_arr_updated_grad = wp.full_like(output_arr_updated, 1.0)
337
+
338
+ cmd.set_param_by_name("input", input_arr_updated)
339
+ cmd.set_param_by_name("output", output_arr_updated)
340
+ cmd.set_param_by_name("input", input_arr_updated_grad, adjoint=True)
341
+ cmd.set_param_by_name("output", output_arr_updated_grad, adjoint=True)
342
+ cmd.set_dim(input_arr_updated.size)
343
+ cmd.launch()
344
+
345
+ assert_np_equal(input_arr_updated_grad.numpy(), np.array([8.0, 10.0, 12.0, 14.0]))
346
+
347
+
277
348
  @wp.kernel
278
- def kernel_mul(
279
- values: wp.array(dtype=int),
280
- coeff: int,
281
- out: wp.array(dtype=int),
282
- ):
349
+ def kernel_mul(values: wp.array(dtype=int), coeff: int, out: wp.array(dtype=int)):
283
350
  tid = wp.tid()
284
351
  out[tid] = values[tid] * coeff
285
352
 
@@ -301,28 +368,10 @@ def test_launch_tuple_args(test, device):
301
368
  )
302
369
  assert_np_equal(out.numpy(), np.array((0, 3, 6, 9)))
303
370
 
304
- wp.launch(
305
- kernel_mul,
306
- dim=len(values),
307
- inputs=(
308
- values,
309
- coeff,
310
- out,
311
- ),
312
- device=device,
313
- )
371
+ wp.launch(kernel_mul, dim=len(values), inputs=(values, coeff, out), device=device)
314
372
  assert_np_equal(out.numpy(), np.array((0, 3, 6, 9)))
315
373
 
316
- wp.launch(
317
- kernel_mul,
318
- dim=len(values),
319
- outputs=(
320
- values,
321
- coeff,
322
- out,
323
- ),
324
- device=device,
325
- )
374
+ wp.launch(kernel_mul, dim=len(values), outputs=(values, coeff, out), device=device)
326
375
  assert_np_equal(out.numpy(), np.array((0, 3, 6, 9)))
327
376
 
328
377
 
@@ -343,6 +392,8 @@ add_function_test(TestLaunch, "test_launch_cmd_set_param", test_launch_cmd_set_p
343
392
  add_function_test(TestLaunch, "test_launch_cmd_set_ctype", test_launch_cmd_set_ctype, devices=devices)
344
393
  add_function_test(TestLaunch, "test_launch_cmd_set_dim", test_launch_cmd_set_dim, devices=devices)
345
394
  add_function_test(TestLaunch, "test_launch_cmd_empty", test_launch_cmd_empty, devices=devices)
395
+ add_function_test(TestLaunch, "test_launch_cmd_adjoint", test_launch_cmd_adjoint, devices=devices)
396
+ add_function_test(TestLaunch, "test_launch_cmd_adjoint_empty", test_launch_cmd_adjoint_empty, devices=devices)
346
397
 
347
398
  add_function_test(TestLaunch, "test_launch_tuple_args", test_launch_tuple_args, devices=devices)
348
399