warp#
The warp package provides array types and functions for creating and manipulating
multi-dimensional data on CPU and CUDA devices. It includes kernel and function decorators
(kernel(), func()) for defining parallel code, along with a comprehensive set
of built-in types and functions for use within kernels (see Built-Ins).
The package provides device management, kernel launch and synchronization functions, automatic
differentiation via Tape recording, type introspection and construction utilities, and
module compilation and caching.
Additional functionality is available in optional submodules that must be explicitly
imported, such as warp.render for visualization, warp.fem for finite
element methods, and warp.sparse for sparse linear algebra.
Submodules#
These modules are automatically available when you import warp.
Additional Submodules#
These modules must be explicitly imported (e.g., import warp.autograd).
Type Annotations#
Data Types#
Scalars#
Boolean scalar type for use in Warp kernels and arrays. |
|
16-bit half-precision floating-point scalar type. |
|
32-bit single-precision floating-point scalar type. |
|
64-bit double-precision floating-point scalar type. |
|
8-bit signed integer scalar type. |
|
16-bit signed integer scalar type. |
|
32-bit signed integer scalar type. |
|
64-bit signed integer scalar type. |
|
8-bit unsigned integer scalar type. |
|
16-bit unsigned integer scalar type. |
|
32-bit unsigned integer scalar type. |
|
64-bit unsigned integer scalar type. |
Vectors#
alias of |
|
alias of |
|
alias of |
|
2D vector with int8 (signed byte) components. |
|
2D vector with float64 (double-precision) components. |
|
2D vector with float32 (single-precision) components. |
|
2D vector with float16 (half-precision) components. |
|
2D vector with int32 (signed integer) components. |
|
2D vector with int64 (signed long) components. |
|
2D vector with int16 (signed short) components. |
|
2D vector with uint8 (unsigned byte) components. |
|
2D vector with uint32 (unsigned integer) components. |
|
2D vector with uint64 (unsigned long) components. |
|
2D vector with uint16 (unsigned short) components. |
|
3D vector with int8 (signed byte) components. |
|
3D vector with float64 (double-precision) components. |
|
3D vector with float32 (single-precision) components. |
|
3D vector with float16 (half-precision) components. |
|
3D vector with int32 (signed integer) components. |
|
3D vector with int64 (signed long) components. |
|
3D vector with int16 (signed short) components. |
|
3D vector with uint8 (unsigned byte) components. |
|
3D vector with uint32 (unsigned integer) components. |
|
3D vector with uint64 (unsigned long) components. |
|
3D vector with uint16 (unsigned short) components. |
|
4D vector with int8 (signed byte) components. |
|
4D vector with float64 (double-precision) components. |
|
4D vector with float32 (single-precision) components. |
|
4D vector with float16 (half-precision) components. |
|
4D vector with int32 (signed integer) components. |
|
4D vector with int64 (signed long) components. |
|
4D vector with int16 (signed short) components. |
|
4D vector with uint8 (unsigned byte) components. |
|
4D vector with uint32 (unsigned integer) components. |
|
4D vector with uint64 (unsigned long) components. |
|
4D vector with uint16 (unsigned short) components. |
Matrices#
alias of |
|
alias of |
|
alias of |
|
2x2 matrix with float64 (double-precision) components. |
|
2x2 matrix with float32 (single-precision) components. |
|
2x2 matrix with float16 (half-precision) components. |
|
3x3 matrix with float64 (double-precision) components. |
|
3x3 matrix with float32 (single-precision) components. |
|
3x3 matrix with float16 (half-precision) components. |
|
4x4 matrix with float64 (double-precision) components. |
|
4x4 matrix with float32 (single-precision) components. |
|
4x4 matrix with float16 (half-precision) components. |
|
Construct a matrix with each vector argument as a column. |
|
Construct a matrix with each vector argument as a row. |
Quaternions#
alias of |
|
Quaternion with float64 (double-precision) components for 3D rotations. |
|
Quaternion with float32 (single-precision) components for 3D rotations. |
|
Quaternion with float16 (half-precision) components for 3D rotations. |
|
Compute the quaternion that rotates vector |
Transformations#
alias of |
|
Rigid-body transformation (position + quaternion) with float64 components. |
|
Rigid-body transformation (position + quaternion) with float32 components. |
|
Rigid-body transformation (position + quaternion) with float16 components. |
|
Expand a flat 7-element sequence into a |
Spatial Vectors and Matrices#
alias of |
|
6x6 spatial matrix with float64 components for rigid-body dynamics. |
|
6x6 spatial matrix with float32 components for rigid-body dynamics. |
|
6x6 spatial matrix with float16 components for rigid-body dynamics. |
|
alias of |
|
6D spatial vector with float64 components for rigid-body dynamics. |
|
6D spatial vector with float32 components for rigid-body dynamics. |
|
6D spatial vector with float16 components for rigid-body dynamics. |
Arrays#
A fixed-size multi-dimensional array containing values of the same type. |
|
A fixed-size, stack allocated, array containing values of the same type. |
|
A Warp tile object. |
|
Create or annotate a 1-dimensional |
|
Create or annotate a 2-dimensional |
|
Create or annotate a 3-dimensional |
|
Create or annotate a 4-dimensional |
|
Clone an existing array, allocating a copy of the src memory. |
|
Copy array contents from src to dest. |
|
Return an uninitialized array. |
|
Return an uninitialized array with the same type and dimension of another array. |
|
Create an array from a raw memory pointer (deprecated). |
|
Return an array with all elements initialized to the given value. |
|
Return an array with all elements initialized to the given value with the same type and dimension of another array. |
|
Return a one-initialized array. |
|
Return a one-initialized array with the same type and dimension of another array. |
|
Return a zero-initialized array. |
|
Return a zero-initialized array with the same type and dimension of another array. |
Indexed Arrays#
Array providing indexed access to a subset of elements in a source |
|
Create or annotate a 1-dimensional |
|
Create or annotate a 2-dimensional |
|
Create or annotate a 3-dimensional |
|
Create or annotate a 4-dimensional |
Spatial Acceleration#
Bounding Volume Hierarchy (BVH) for accelerated spatial queries. |
|
Object used to track state during BVH traversal. |
|
Object used to track state during thread-block parallel BVH traversal. |
|
Hash-based spatial grid for accelerated neighbor queries on point data. |
|
Object used to track state during neighbor traversal. |
|
Triangle mesh for collision detection, ray casting, and spatial queries. |
|
Object used to track state during mesh traversal. |
|
Object used to track state during thread-block parallel mesh traversal. |
|
Output for the mesh query point functions. |
|
Output for the mesh query ray functions. |
|
Sparse volumetric data structure based on NanoVDB for efficient 3D sampling. |
Runtime#
Clear the kernel cache directory of previously generated source code and compiler artifacts. |
|
Clear the LTO cache directory of previously generated LTO code. |
|
Initialize the Warp runtime. |
|
Check whether CPU execution is available. |
|
Check whether CUDA execution is available. |
Kernel Programming#
Attribute error during Warp kernel code generation. |
|
General error during Warp kernel code generation. |
|
Index error during Warp kernel code generation. |
|
Key error during Warp kernel code generation. |
|
Type error during Warp kernel code generation. |
|
Value error during Warp kernel code generation. |
|
Decorator to define a Warp function callable from kernels and other Warp functions. |
|
Decorator to register a custom gradient function for a given forward function. |
|
Decorator to register native code snippet, @func_native |
|
Decorator to register a custom replay function for a given forward function. |
|
Return a callable that computes the gradient of the given function. |
|
Decorator to register a Warp kernel from a Python function. |
|
Map a function over the elements of one or more arrays. |
|
Overload a generic kernel with the given argument types. |
|
Evaluate a static expression and replace the expression with its result. |
|
Decorator to define a Warp struct for use in kernels and functions. |
Kernel Execution#
Represents a Warp function decorated with |
|
Warp kernel object, typically created by decorating a Python function with |
|
Represent all data required for a kernel launch so that launches can be replayed quickly. |
|
Warp module containing kernels and functions to be compiled. |
|
Launch a Warp kernel on the target device |
|
A helper method for launching a grid with an extra trailing dimension equal to the block size. |
|
Manually synchronize the calling CPU thread with any outstanding CUDA work on all devices |
Automatic Differentiation#
Record kernel launches within a Tape scope to enable automatic differentiation. |
Device Management#
A device to allocate Warp arrays and to launch kernels on. |
|
A context manager to temporarily change the current default device. |
|
Return the CUDA device with the given ordinal or the current CUDA device if ordinal is |
|
Return the number of CUDA devices supported in this environment. |
|
Return a list of CUDA devices supported in this environment. |
|
Return a sorted list of CUDA compute architectures that can be used as compilation targets. |
|
Return the device identified by the argument. |
|
Return a list of devices supported in this environment. |
|
Return the preferred compute device, |
|
Check whether a device is available in the current environment. |
|
Assign a device alias to a CUDA context. |
|
Set the default device identified by the argument. |
|
Synchronize the calling CPU thread with any outstanding CUDA work on the specified device |
|
Remove a CUDA device with the given alias. |
Module Management#
Compile a module (ahead of time) for a given device. |
|
Force user-defined kernels to be compiled and loaded (low-level API). |
|
Return or create the Warp module associated with a given name. |
|
Return a list of options for the current module. |
|
Load a previously compiled module (ahead of time). |
|
Force a user-defined module to be compiled and loaded. |
|
Set options for the current module. |
CUDA Stream Management#
A context manager to temporarily change the current stream on a device. |
|
CUDA stream wrapper for managing asynchronous GPU operations. |
|
Return the stream currently used by the given device. |
|
Convenience function for calling |
|
Synchronize the calling CPU thread with any outstanding CUDA work on the specified stream. |
|
Convenience function for calling |
CUDA Event Management#
A CUDA event that can be recorded onto a stream. |
|
Get the elapsed time between two recorded events. |
|
Convenience function for calling |
|
Synchronize the calling CPU thread with an event recorded on a CUDA stream. |
|
Convenience function for calling |
CUDA Memory Management#
Context manager to temporarily enable or disable memory pool allocators. |
|
Context manager to temporarily enable or disable mempool access between devices. |
|
Context manager to temporarily enable or disable peer access between CUDA devices. |
|
Get the CUDA memory pool release threshold on the device. |
|
Get the amount of memory from the device's memory pool that is currently in use by the application. |
|
Get the application's memory usage high-water mark from the device's CUDA memory pool. |
|
Check if |
|
Check if |
|
Check if CUDA memory pool allocators are enabled on the device. |
|
Check if CUDA memory pool allocators are available on the device. |
|
Check if |
|
Check if |
|
Enable or disable access from |
|
Enable or disable CUDA memory pool allocators on the device. |
|
Set the CUDA memory pool release threshold on the device. |
|
Enable or disable direct access from |
CUDA Graph Management#
Context manager to capture a sequence of operations into a CUDA graph. |
|
Begin capture of a CUDA graph |
|
Export a CUDA graph to a DOT file for visualization |
|
End the capture of a CUDA graph. |
|
Create a dynamic branch based on a condition. |
|
Launch a previously captured CUDA graph |
|
Create a dynamic loop based on a condition. |
|
Check whether conditional graph nodes are supported. |
CUDA Interprocess Communication#
Create an event from an IPC handle. |
|
Create an array from an IPC handle. |
Profiling#
Context manager for timing code blocks. |
|
Timing result for a single activity. |
|
Begin detailed activity timing. |
|
End detailed activity timing. |
|
Print timing results. |
Timing Flags#
Timing flag to capture all CUDA activities. |
|
Timing flag for CUDA graph launches. |
|
Timing flag for user-defined kernel launches. |
|
Timing flag for built-in kernel operations (e.g., array fill, copy). |
|
Timing flag for memory copy operations. |
|
Timing flag for memory set operations. |
NumPy Interop#
Return the Warp dtype corresponding to a NumPy dtype. |
|
Return the NumPy dtype corresponding to a Warp dtype. |
|
Return a Warp array created from a NumPy array. |
DLPack Interop#
Convert a source array or DLPack capsule into a Warp array without copying. |
|
Convert a Warp array to another type of DLPack-compatible array. |
JAX Interop#
Return the Warp device corresponding to a Jax device. |
|
Return the Jax device corresponding to a Warp device. |
|
Return the Warp dtype corresponding to a Jax dtype. |
|
Return the Jax dtype corresponding to a Warp dtype. |
|
Convert a Jax array to a Warp array without copying the data. |
|
Convert a Warp array to a Jax array without copying the data. |
PyTorch Interop#
Return the Warp device corresponding to a Torch device. |
|
Return the Torch device string corresponding to a Warp device. |
|
Return the Warp dtype corresponding to a Torch dtype. |
|
Return the Torch dtype corresponding to a Warp dtype. |
|
Convert a Torch tensor to a Warp array without copying the data. |
|
Convert from a Torch CUDA stream to a Warp CUDA stream. |
|
Convert from a Warp CUDA stream to a Torch CUDA stream. |
|
Convert a Warp array to a Torch tensor without copying the data. |
Omniverse Runtime Fabric Interop#
Array type for accessing data stored in Omniverse Runtime Fabric. |
|
Indexed view into a |
|
Create a Fabric array of arrays (2D fabric array). |
|
Create an indexed Fabric array of arrays (2D indexed fabric array). |
Paddle Interop#
Return the Warp device corresponding to a Paddle device. |
|
Return the Paddle device string corresponding to a Warp device. |
|
Return the Warp dtype corresponding to a Paddle dtype. |
|
Return the Paddle dtype corresponding to a Warp dtype. |
|
Convert a Paddle tensor to a Warp array without copying the data. |
|
Convert from a Paddle CUDA stream to a Warp CUDA stream. |
|
Convert a Warp array to a Paddle tensor without copying the data. |
Constants#
Function to declare compile-time constants accessible from Warp kernels |
|
Euler's number e (approximately 2.718). |
|
Half of pi (approximately 1.571). |
|
Positive infinity. |
|
Natural logarithm of 2 (approximately 0.693). |
|
Natural logarithm of 10 (approximately 2.303). |
|
Base-10 logarithm of e (approximately 0.434). |
|
Base-2 logarithm of e (approximately 1.443). |
|
Not a Number (NaN). |
|
Golden ratio (approximately 1.618). |
|
Pi (approximately 3.14159). |
|
Tau, the circle constant equal to 2*pi (approximately 6.283). |
|
Euler's number e (approximately 2.718). |
|
Half of pi (approximately 1.571). |
|
Positive infinity. |
|
Natural logarithm of 2 (approximately 0.693). |
|
Natural logarithm of 10 (approximately 2.303). |
|
Base-10 logarithm of e (approximately 0.434). |
|
Base-2 logarithm of e (approximately 1.443). |
|
Not a Number (NaN). |
|
Golden ratio (approximately 1.618). |
|
Pi (approximately 3.14159). |
|
Tau, the circle constant equal to 2*pi (approximately 6.283). |
Misc#
A reusable context for marching cubes surface extraction. |
|
Helper class to register a GL buffer with CUDA so that it can be mapped to a Warp array. |