warp-lang 1.3.3__py3-none-manylinux2014_aarch64.whl → 1.4.1__py3-none-manylinux2014_aarch64.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 (110) hide show
  1. warp/__init__.py +6 -0
  2. warp/autograd.py +59 -6
  3. warp/bin/warp.so +0 -0
  4. warp/build_dll.py +8 -10
  5. warp/builtins.py +103 -3
  6. warp/codegen.py +447 -53
  7. warp/config.py +1 -1
  8. warp/context.py +682 -405
  9. warp/dlpack.py +2 -0
  10. warp/examples/benchmarks/benchmark_cloth.py +10 -0
  11. warp/examples/core/example_render_opengl.py +12 -10
  12. warp/examples/fem/example_adaptive_grid.py +251 -0
  13. warp/examples/fem/example_apic_fluid.py +1 -1
  14. warp/examples/fem/example_diffusion_3d.py +2 -2
  15. warp/examples/fem/example_magnetostatics.py +1 -1
  16. warp/examples/fem/example_streamlines.py +1 -0
  17. warp/examples/fem/utils.py +25 -5
  18. warp/examples/sim/example_cloth.py +50 -6
  19. warp/fem/__init__.py +2 -0
  20. warp/fem/adaptivity.py +493 -0
  21. warp/fem/field/field.py +2 -1
  22. warp/fem/field/nodal_field.py +18 -26
  23. warp/fem/field/test.py +4 -4
  24. warp/fem/field/trial.py +4 -4
  25. warp/fem/geometry/__init__.py +1 -0
  26. warp/fem/geometry/adaptive_nanogrid.py +843 -0
  27. warp/fem/geometry/nanogrid.py +55 -28
  28. warp/fem/space/__init__.py +1 -1
  29. warp/fem/space/nanogrid_function_space.py +69 -35
  30. warp/fem/utils.py +118 -107
  31. warp/jax_experimental.py +28 -15
  32. warp/native/array.h +0 -1
  33. warp/native/builtin.h +103 -6
  34. warp/native/bvh.cu +4 -2
  35. warp/native/cuda_util.cpp +14 -0
  36. warp/native/cuda_util.h +2 -0
  37. warp/native/error.cpp +4 -2
  38. warp/native/exports.h +99 -0
  39. warp/native/mat.h +97 -0
  40. warp/native/mesh.cpp +36 -0
  41. warp/native/mesh.cu +52 -1
  42. warp/native/mesh.h +1 -0
  43. warp/native/quat.h +43 -0
  44. warp/native/range.h +11 -2
  45. warp/native/spatial.h +6 -0
  46. warp/native/vec.h +74 -0
  47. warp/native/warp.cpp +2 -1
  48. warp/native/warp.cu +10 -3
  49. warp/native/warp.h +8 -1
  50. warp/paddle.py +382 -0
  51. warp/sim/__init__.py +1 -0
  52. warp/sim/collide.py +519 -0
  53. warp/sim/integrator_euler.py +18 -5
  54. warp/sim/integrator_featherstone.py +5 -5
  55. warp/sim/integrator_vbd.py +1026 -0
  56. warp/sim/integrator_xpbd.py +2 -6
  57. warp/sim/model.py +50 -25
  58. warp/sparse.py +9 -7
  59. warp/stubs.py +459 -0
  60. warp/tape.py +2 -0
  61. warp/tests/aux_test_dependent.py +1 -0
  62. warp/tests/aux_test_name_clash1.py +32 -0
  63. warp/tests/aux_test_name_clash2.py +32 -0
  64. warp/tests/aux_test_square.py +1 -0
  65. warp/tests/test_array.py +188 -0
  66. warp/tests/test_async.py +3 -3
  67. warp/tests/test_atomic.py +6 -0
  68. warp/tests/test_closest_point_edge_edge.py +93 -1
  69. warp/tests/test_codegen.py +93 -15
  70. warp/tests/test_codegen_instancing.py +1457 -0
  71. warp/tests/test_collision.py +486 -0
  72. warp/tests/test_compile_consts.py +3 -28
  73. warp/tests/test_dlpack.py +170 -0
  74. warp/tests/test_examples.py +22 -8
  75. warp/tests/test_fast_math.py +10 -4
  76. warp/tests/test_fem.py +81 -1
  77. warp/tests/test_func.py +46 -0
  78. warp/tests/test_implicit_init.py +49 -0
  79. warp/tests/test_jax.py +58 -0
  80. warp/tests/test_mat.py +84 -0
  81. warp/tests/test_mesh_query_point.py +188 -0
  82. warp/tests/test_model.py +13 -0
  83. warp/tests/test_module_hashing.py +40 -0
  84. warp/tests/test_multigpu.py +3 -3
  85. warp/tests/test_overwrite.py +8 -0
  86. warp/tests/test_paddle.py +852 -0
  87. warp/tests/test_print.py +89 -0
  88. warp/tests/test_quat.py +111 -0
  89. warp/tests/test_reload.py +31 -1
  90. warp/tests/test_scalar_ops.py +2 -0
  91. warp/tests/test_static.py +568 -0
  92. warp/tests/test_streams.py +64 -3
  93. warp/tests/test_struct.py +4 -4
  94. warp/tests/test_torch.py +24 -0
  95. warp/tests/test_triangle_closest_point.py +137 -0
  96. warp/tests/test_types.py +1 -1
  97. warp/tests/test_vbd.py +386 -0
  98. warp/tests/test_vec.py +143 -0
  99. warp/tests/test_vec_scalar_ops.py +139 -0
  100. warp/tests/unittest_suites.py +12 -0
  101. warp/tests/unittest_utils.py +9 -5
  102. warp/thirdparty/dlpack.py +3 -1
  103. warp/types.py +167 -36
  104. warp/utils.py +37 -14
  105. {warp_lang-1.3.3.dist-info → warp_lang-1.4.1.dist-info}/METADATA +10 -8
  106. {warp_lang-1.3.3.dist-info → warp_lang-1.4.1.dist-info}/RECORD +109 -97
  107. warp/tests/test_point_triangle_closest_point.py +0 -143
  108. {warp_lang-1.3.3.dist-info → warp_lang-1.4.1.dist-info}/LICENSE.md +0 -0
  109. {warp_lang-1.3.3.dist-info → warp_lang-1.4.1.dist-info}/WHEEL +0 -0
  110. {warp_lang-1.3.3.dist-info → warp_lang-1.4.1.dist-info}/top_level.txt +0 -0
warp/__init__.py CHANGED
@@ -99,11 +99,17 @@ from warp.jax import device_from_jax, device_to_jax
99
99
 
100
100
  from warp.dlpack import from_dlpack, to_dlpack
101
101
 
102
+ from warp.paddle import from_paddle, to_paddle
103
+ from warp.paddle import dtype_from_paddle, dtype_to_paddle
104
+ from warp.paddle import device_from_paddle, device_to_paddle
105
+ from warp.paddle import stream_from_paddle
106
+
102
107
  from warp.build import clear_kernel_cache
103
108
 
104
109
  from warp.constants import *
105
110
 
106
111
  from . import builtins
112
+ from warp.builtins import static
107
113
 
108
114
  import warp.config as config
109
115
 
warp/autograd.py CHANGED
@@ -17,7 +17,7 @@ __all__ = [
17
17
  "jacobian_fd",
18
18
  "gradcheck",
19
19
  "gradcheck_tape",
20
- "plot_kernel_jacobians",
20
+ "jacobian_plot",
21
21
  ]
22
22
 
23
23
 
@@ -182,7 +182,7 @@ def gradcheck(
182
182
  else:
183
183
  print(FontColors.OKGREEN + f"Gradient check for kernel {function.key} passed" + FontColors.ENDC)
184
184
  if plot_relative_error:
185
- plot_kernel_jacobians(
185
+ jacobian_plot(
186
186
  relative_error_jacs,
187
187
  function,
188
188
  inputs,
@@ -190,7 +190,7 @@ def gradcheck(
190
190
  title=f"{function.key} kernel Jacobian relative error",
191
191
  )
192
192
  if plot_absolute_error:
193
- plot_kernel_jacobians(
193
+ jacobian_plot(
194
194
  absolute_error_jacs,
195
195
  function,
196
196
  inputs,
@@ -307,7 +307,7 @@ def infer_device(xs: list):
307
307
  return wp.get_preferred_device()
308
308
 
309
309
 
310
- def plot_kernel_jacobians(
310
+ def jacobian_plot(
311
311
  jacobians: Dict[Tuple[int, int], wp.array],
312
312
  kernel: wp.Kernel,
313
313
  inputs: Sequence,
@@ -515,6 +515,59 @@ def plot_kernel_jacobians(
515
515
  return fig
516
516
 
517
517
 
518
+ def plot_kernel_jacobians(
519
+ jacobians: Dict[Tuple[int, int], wp.array],
520
+ kernel: wp.Kernel,
521
+ inputs: Sequence,
522
+ outputs: Sequence,
523
+ show_plot=True,
524
+ show_colorbar=True,
525
+ scale_colors_per_submatrix=False,
526
+ title: str = None,
527
+ colormap: str = "coolwarm",
528
+ log_scale=False,
529
+ ):
530
+ """
531
+ Visualizes the Jacobians computed by :func:`jacobian` or :func:`jacobian_fd` in a combined image plot.
532
+ Requires the ``matplotlib`` package to be installed.
533
+
534
+ Note:
535
+ This function is deprecated and will be removed in a future Warp version. Please call :func:`jacobian_plot` instead.
536
+
537
+ Args:
538
+ jacobians: A dictionary of Jacobians, where the keys are tuples of input and output indices, and the values are the Jacobian matrices.
539
+ kernel: The Warp kernel function, decorated with the ``@wp.kernel`` decorator.
540
+ inputs: List of input variables.
541
+ outputs: List of output variables.
542
+ show_plot: If True, displays the plot via ``plt.show()``.
543
+ show_colorbar: If True, displays a colorbar next to the plot (or a colorbar next to every submatrix if ).
544
+ scale_colors_per_submatrix: If True, considers the minimum and maximum of each Jacobian submatrix separately for color scaling. Otherwise, uses the global minimum and maximum of all Jacobians.
545
+ title: The title of the plot (optional).
546
+ colormap: The colormap to use for the plot.
547
+ log_scale: If True, uses a logarithmic scale for the matrix values shown in the image plot.
548
+
549
+ Returns:
550
+ The created Matplotlib figure.
551
+ """
552
+ wp.utils.warn(
553
+ "The function `plot_kernel_jacobians` is deprecated and will be removed in a future Warp version. Please call `jacobian_plot` instead.",
554
+ DeprecationWarning,
555
+ stacklevel=3,
556
+ )
557
+ return jacobian_plot(
558
+ jacobians,
559
+ kernel,
560
+ inputs,
561
+ outputs,
562
+ show_plot=show_plot,
563
+ show_colorbar=show_colorbar,
564
+ scale_colors_per_submatrix=scale_colors_per_submatrix,
565
+ title=title,
566
+ colormap=colormap,
567
+ log_scale=log_scale,
568
+ )
569
+
570
+
518
571
  def scalarize_array_1d(arr):
519
572
  # convert array to 1D array with scalar dtype
520
573
  if arr.dtype in wp.types.scalar_types:
@@ -638,7 +691,7 @@ def jacobian(
638
691
  jacobians[input_i, output_i] = jacobian
639
692
 
640
693
  if plot_jacobians:
641
- plot_kernel_jacobians(
694
+ jacobian_plot(
642
695
  jacobians,
643
696
  kernel,
644
697
  inputs,
@@ -753,7 +806,7 @@ def jacobian_fd(
753
806
  jacobians[input_i, output_i] = jacobian
754
807
 
755
808
  if plot_jacobians:
756
- plot_kernel_jacobians(
809
+ jacobian_plot(
757
810
  jacobians,
758
811
  kernel,
759
812
  inputs,
warp/bin/warp.so CHANGED
Binary file
warp/build_dll.py CHANGED
@@ -32,13 +32,12 @@ def run_cmd(cmd):
32
32
  print(cmd)
33
33
 
34
34
  try:
35
- return subprocess.check_output(cmd, shell=True)
35
+ return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
36
36
  except subprocess.CalledProcessError as e:
37
- if e.stdout:
38
- print(e.stdout.decode())
39
- if e.stderr:
40
- print(e.stderr.decode())
41
- raise (e)
37
+ print("Command failed with exit code:", e.returncode)
38
+ print("Command output was:")
39
+ print(e.output.decode())
40
+ raise e
42
41
 
43
42
 
44
43
  # cut-down version of vcvars64.bat that allows using
@@ -157,7 +156,6 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
157
156
 
158
157
  warp_home_path = pathlib.Path(__file__).parent
159
158
  warp_home = warp_home_path.resolve()
160
- nanovdb_home = warp_home_path.parent / "_build/host-deps/nanovdb/include"
161
159
 
162
160
  # output stale, rebuild
163
161
  if args.verbose:
@@ -246,7 +244,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
246
244
  iter_dbg = "_ITERATOR_DEBUG_LEVEL=2"
247
245
  debug = "_DEBUG"
248
246
 
249
- cpp_flags = f'/nologo /std:c++17 /GR- {runtime} /D "{debug}" /D "{cuda_enabled}" /D "{cutlass_enabled}" /D "{cuda_compat_enabled}" /D "{iter_dbg}" /I"{native_dir}" /I"{nanovdb_home}" {includes} '
247
+ cpp_flags = f'/nologo /std:c++17 /GR- {runtime} /D "{debug}" /D "{cuda_enabled}" /D "{cutlass_enabled}" /D "{cuda_compat_enabled}" /D "{iter_dbg}" /I"{native_dir}" {includes} '
250
248
 
251
249
  if args.mode == "debug":
252
250
  cpp_flags += "/Zi /Od /D WP_ENABLE_DEBUG=1"
@@ -275,10 +273,10 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None
275
273
  cu_out = cu_path + ".o"
276
274
 
277
275
  if mode == "debug":
278
- cuda_cmd = f'"{cuda_home}/bin/nvcc" --compiler-options=/MT,/Zi,/Od -g -G -O0 -DNDEBUG -D_ITERATOR_DEBUG_LEVEL=0 -I"{native_dir}" -I"{nanovdb_home}" -line-info {" ".join(nvcc_opts)} -DWP_ENABLE_CUDA=1 -D{cutlass_enabled} {cutlass_includes} -o "{cu_out}" -c "{cu_path}"'
276
+ cuda_cmd = f'"{cuda_home}/bin/nvcc" --compiler-options=/MT,/Zi,/Od -g -G -O0 -DNDEBUG -D_ITERATOR_DEBUG_LEVEL=0 -I"{native_dir}" -line-info {" ".join(nvcc_opts)} -DWP_ENABLE_CUDA=1 -D{cutlass_enabled} {cutlass_includes} -o "{cu_out}" -c "{cu_path}"'
279
277
 
280
278
  elif mode == "release":
281
- cuda_cmd = f'"{cuda_home}/bin/nvcc" -O3 {" ".join(nvcc_opts)} -I"{native_dir}" -I"{nanovdb_home}" -DNDEBUG -DWP_ENABLE_CUDA=1 -D{cutlass_enabled} {cutlass_includes} -o "{cu_out}" -c "{cu_path}"'
279
+ cuda_cmd = f'"{cuda_home}/bin/nvcc" -O3 {" ".join(nvcc_opts)} -I"{native_dir}" -DNDEBUG -DWP_ENABLE_CUDA=1 -D{cutlass_enabled} {cutlass_includes} -o "{cu_out}" -c "{cu_path}"'
282
280
 
283
281
  with ScopedTimer("build_cuda", active=args.verbose):
284
282
  run_cmd(cuda_cmd)
warp/builtins.py CHANGED
@@ -1533,7 +1533,7 @@ add_builtin(
1533
1533
 
1534
1534
  def spatial_vector_value_func(arg_types: Mapping[str, type], arg_values: Mapping[str, Any]):
1535
1535
  if arg_types is None:
1536
- return spatial_vector(dtype=Float)
1536
+ return vector(length=6, dtype=Float)
1537
1537
 
1538
1538
  dtype = arg_values.get("dtype", None)
1539
1539
 
@@ -3639,6 +3639,30 @@ add_builtin(
3639
3639
  )
3640
3640
 
3641
3641
 
3642
+ def vector_assign_value_func(arg_types: Mapping[str, type], arg_values: Mapping[str, Any]):
3643
+ vec_type = arg_types["a"]
3644
+ return vec_type
3645
+
3646
+
3647
+ # implements vector[index] = value
3648
+ add_builtin(
3649
+ "assign",
3650
+ input_types={"a": vector(length=Any, dtype=Scalar), "i": int, "value": Scalar},
3651
+ value_func=vector_assign_value_func,
3652
+ hidden=True,
3653
+ group="Utility",
3654
+ )
3655
+
3656
+ # implements quaternion[index] = value
3657
+ add_builtin(
3658
+ "assign",
3659
+ input_types={"a": quaternion(dtype=Scalar), "i": int, "value": Scalar},
3660
+ value_func=vector_assign_value_func,
3661
+ hidden=True,
3662
+ group="Utility",
3663
+ )
3664
+
3665
+
3642
3666
  def matrix_index_row_value_func(arg_types: Mapping[str, type], arg_values: Mapping[str, Any]):
3643
3667
  mat_type = arg_types["a"]
3644
3668
  row_type = mat_type._wp_row_type_
@@ -3646,7 +3670,7 @@ def matrix_index_row_value_func(arg_types: Mapping[str, type], arg_values: Mappi
3646
3670
  return Reference(row_type)
3647
3671
 
3648
3672
 
3649
- # implements matrix[i] = row
3673
+ # implements &matrix[i] = row
3650
3674
  add_builtin(
3651
3675
  "index",
3652
3676
  input_types={"a": matrix(shape=(Any, Any), dtype=Scalar), "i": int},
@@ -3664,7 +3688,7 @@ def matrix_index_value_func(arg_types: Mapping[str, type], arg_values: Mapping[s
3664
3688
  return Reference(value_type)
3665
3689
 
3666
3690
 
3667
- # implements matrix[i,j] = scalar
3691
+ # implements &matrix[i,j] = scalar
3668
3692
  add_builtin(
3669
3693
  "index",
3670
3694
  input_types={"a": matrix(shape=(Any, Any), dtype=Scalar), "i": int, "j": int},
@@ -3674,6 +3698,41 @@ add_builtin(
3674
3698
  skip_replay=True,
3675
3699
  )
3676
3700
 
3701
+
3702
+ def matrix_assign_value_func(arg_types: Mapping[str, type], arg_values: Mapping[str, Any]):
3703
+ mat_type = arg_types["a"]
3704
+ return mat_type
3705
+
3706
+
3707
+ def matrix_vector_sametype(arg_types: Mapping[str, Any]):
3708
+ mat_size = arg_types["a"]._shape_[0]
3709
+ vec_size = arg_types["value"]._length_
3710
+ mat_type = arg_types["a"]._type_
3711
+ vec_type = arg_types["value"]._type_
3712
+ return mat_size == vec_size and mat_type == vec_type
3713
+
3714
+
3715
+ # implements matrix[i,j] = scalar
3716
+ add_builtin(
3717
+ "assign",
3718
+ input_types={"a": matrix(shape=(Any, Any), dtype=Scalar), "i": int, "j": int, "value": Scalar},
3719
+ value_func=matrix_assign_value_func,
3720
+ hidden=True,
3721
+ group="Utility",
3722
+ )
3723
+
3724
+
3725
+ # implements matrix[i] = vector
3726
+ add_builtin(
3727
+ "assign",
3728
+ input_types={"a": matrix(shape=(Any, Any), dtype=Scalar), "i": int, "value": vector(length=Any, dtype=Scalar)},
3729
+ constraint=matrix_vector_sametype,
3730
+ value_func=matrix_assign_value_func,
3731
+ hidden=True,
3732
+ group="Utility",
3733
+ )
3734
+
3735
+
3677
3736
  for t in scalar_types + vector_types + (bool,):
3678
3737
  if "vec" in t.__name__ or "mat" in t.__name__:
3679
3738
  continue
@@ -4107,6 +4166,14 @@ add_builtin(
4107
4166
  doc="Modulo operation using truncated division.",
4108
4167
  group="Operators",
4109
4168
  )
4169
+ add_builtin(
4170
+ "mod",
4171
+ input_types={"a": vector(length=Any, dtype=Scalar), "b": vector(length=Any, dtype=Scalar)},
4172
+ constraint=sametypes,
4173
+ value_func=sametypes_create_value_func(Scalar),
4174
+ doc="Modulo operation using truncated division.",
4175
+ group="Operators",
4176
+ )
4110
4177
 
4111
4178
  add_builtin(
4112
4179
  "div",
@@ -4218,3 +4285,36 @@ for t in int_types:
4218
4285
 
4219
4286
 
4220
4287
  add_builtin("unot", input_types={"a": array(dtype=Any)}, value_type=builtins.bool, doc="", group="Operators")
4288
+
4289
+ # ---------------------------------
4290
+ # Code Generation
4291
+
4292
+ add_builtin(
4293
+ "static",
4294
+ input_types={"expr": Any},
4295
+ value_type=Any,
4296
+ doc="""Evaluates a static Python expression and replaces it with its result.
4297
+
4298
+ See the `codegen.html#static-expressions <section on code generation>`_ for more details.
4299
+
4300
+ Note:
4301
+ The inner expression must only reference variables that are available from the current scope where the Warp kernel or function containing the expression is defined,
4302
+ which includes constant variables and variables captured in the current closure in which the function or kernel is implemented.
4303
+ The return type of the expression must be either a Warp function, a string, or a type that is supported inside Warp kernels and functions
4304
+ (excluding Warp arrays since they cannot be created in a Warp kernel at the moment).""",
4305
+ group="Code Generation",
4306
+ )
4307
+
4308
+
4309
+ def static(expr):
4310
+ """
4311
+ Evaluates a static expression and replaces the expression with its result.
4312
+
4313
+ Args:
4314
+ expr: A Python expression to evaluate. Must return a non-null value which must be either a Warp function, a string, or a type that is supported inside Warp kernels and functions (excluding Warp arrays since they cannot be created in a Warp kernel at the moment).
4315
+
4316
+ Note:
4317
+ The inner expression must only reference variables that are available from the current scope where the Warp kernel or function containing the expression is defined,
4318
+ which includes constant variables and variables captured in the current closure in which the function or kernel is implemented.
4319
+ """
4320
+ return expr