Repository navigation
v1.20.0 #2482
shi-eric
announced in
Announcements
v1.20.0
#2482
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Warp v1.20.0
New features
Forward-mode derivatives with jets
Important
This is an experimental feature. The API may change without a formal deprecation cycle.
Warp 1.20 adds experimental forward-mode jets. A jet carries derivatives along with its value, so one forward pass through an ordinary
@wp.funcwithAny-typed parameters returns the value, gradient, and dense Hessian without hand-written derivatives. Seed the inputs withwp.JetSpace()for first derivatives or withwp.JetSpace2()to add second derivatives (#1813).Jets help when every thread needs derivatives of a small function with a few inputs, as in a per-thread Newton solve. Reverse mode on its own gives only first derivatives, one output per backward sweep. Jets also work with
wp.Tape, so reverse mode over first-order jets gives Hessian-vector products.Output:
The same
rosenbrockfunction still accepts plain floats. Jet inputs can be scalars,wp.vec2,wp.vec3, orwp.quatvalues, and first-order spaces also acceptwp.mat22,wp.mat33,wp.mat32, andwp.mat23. Double-precision types work too. To branch on a value, usewp.value(), which accepts both jets and plain floats.Every intermediate jet carries all seeded directions, and second-order jets also carry the full Hessian. Register use and compile time therefore grow linearly with the number of inputs for first-order jets and quadratically for second-order jets. Kernels that only use jets can skip reverse-mode code generation with
enable_backward=False, as in the example.wp.mesh_query_point()and other built-ins without jet support accept plain values only.The quaternion shape alignment example runs a Newton solve for every candidate molecule in parallel using rotation gradients and Hessians from quaternion jets. The implicit projection example moves points onto an implicit surface with first- and second-order jets.
Documentation
Reusable Krylov solves
The new
warp.optim.linear.KrylovSolvesets up a CG, CR, BiCGSTAB, or GMRES solve once and allocates its workspace up front (#2205). Eachsolve()call then writes the solutions for new right-hand sides into arrays you provide. This helps code that solves with the same sparse operator many times, as in implicit time stepping or the inner solves of an eigenvalue method.One call can solve several right-hand sides as independent systems and start from an initial guess. Iteration counts and residuals stay in device arrays, so solves can be captured in CUDA graphs after a warm-up call.
Later solves use coefficients changed in place, as the example shows, but changing the sparsity pattern requires a new
KrylovSolve. A fixed preconditioner can be passed asM. Unlikecg()and the other solver functions,KrylovSolvedefaultsatolto0.0. It does not support reverse-mode differentiation.For a
wp.float64matrix,working_dtype=wp.float32runs the iterations in single precision. Withresidual="fresh", convergence is judged on a residual recomputed in double precision after each solve.warp.sparse.bsr_mv()now also accepts a contiguous 2-D array with one vector per row, so one call multiplies a sparse matrix by a batch of vectors.KrylovSolveuses it for multiple right-hand sides (#2204). Thealgorithmargument selects how the batch is computed.Documentation
Differentiable sparse matrix products
warp.sparse.bsr_mv()andwarp.sparse.bsr_mm()now record their adjoints on awp.Tape, so simulations and optimizations that apply sparse operators can differentiate through them. Gradients flow to the input vector and to the stored values of the input matrices (#2286, #2287). In Warp 1.19,tape.backward()returned all-zero gradients throughbsr_mv()with only a warning. Throughbsr_mm(), it raised anAttributeError.Gradients reach only the stored blocks. Keep the
bsr_mm()output separate from both operands. Differentiating an aliased product such asA @= BraisesNotImplementedError.Documentation
LU and LDLᵀ factorizations for tiles
Kernels can now factor general and symmetric indefinite matrices on tiles.
wp.tile_cholesky()handles only symmetric positive-definite matrices, so other matrices previously needed a separate solver outside the kernel. Symmetric indefinite matrices include constrained-optimization (KKT) systems and indefinite Newton Hessians.lu, pivots, info = wp.tile_lu(A)computes an LU factorization with partial pivoting (#2237).ld, pivots, info = wp.tile_ldlt(A)computes a Bunch-Kaufman LDLᵀ factorization of a symmetric matrix that may be indefinite (#2238). It uses symmetric row and column interchanges, andDhas 1×1 and 2×2 diagonal blocks. Both functions accept squarewp.float32andwp.float64tiles on CPU and CUDA.Each function returns the factors packed into one tile, the pivot sequence, and a status that reports the first exactly zero pivot. For LU, the packed tile holds
Uon and above the diagonal and the unit lower triangularLbelow it, with its ones implied. Thewp.tile_ldlt()reference describes how the pivots mark the 2×2 blocks. Gradients flow through the factors with the pivots held fixed.wp.tile_cholesky_solve()solvesA x = bfrom a Cholesky factor, but the new factorizations have no matching solve function yet. To solve a system with them, write the solve in the kernel. For LU, apply the row swaps inpivotstob, then do forward substitution withLand back substitution withU, as thewp.tile_lu()reference shows.On CUDA, the
wp.tile_ldlt()adjoint needs extra shared memory in kernels compiled with backward support, which can limit the tile size. The shared memory budget section describes forward-only options.Continuous FEM spaces on adaptive grids and periodic domains
The new
warp.fem.make_conforming_basis_space(basis)keeps fields continuous across refinement levels on awarp.fem.AdaptiveNanogrid. Previously, the nodes where a fine cell meets a coarser neighbor were independent unknowns, so fields could jump wherever the resolution changed. The conforming space ties each of these hanging nodes to the values interpolated from the coarser cell.The same constraint mechanism handles periodic boundary conditions.
warp.fem.periodic_prolongation()ties nodes to their translated copies, andwarp.fem.make_constrained_basis_space()builds a constrained space from a sparse prolongation matrix such as this one (#2117).The periodic homogenization example combines both constraints to compute a composite material's effective conductivity on adaptive grids. Constrained spaces do not support nodal assembly, so assemble Dirichlet projectors on the original basis and restrict them with the constrained basis's
reduce_dirichlet_projector()method. Rebuild a constrained space after its geometry changes.Documentation
In-place Dirichlet conditions in
warp.femwarp.fem.project_linear_system()andwarp.fem.project_system_matrix()accept a newprojector_structure="block_diagonal"option that projects the system matrix in place (#2118). The matrix keeps its sparsity pattern, and the projection works during graph capture without temporary matrices or host synchronization. Time-stepping and Newton loops can then reapply strong Dirichlet conditions at every step inside a captured graph.The option applies to block-diagonal projectors, such as those assembled with
warp.fem.integrate(..., assembly="nodal"). Keep the default"general"for projectors with off-diagonal blocks or when a constrained row of the matrix has no stored diagonal block.Documentation
Oriented bounding boxes and intersection tests
The new
warp.geometry.oriented_bounding_box()fits an oriented box to a point set on the device. The fit approximately minimizes the box's volume, surface area, or mean width.warp.geometry.oriented_bounding_boxes()fits many point sets in one call (#1950). Both functions keep their results on the device and can be captured in a CUDA graph, so a captured simulation step can refit its boxes without a round trip to the host. For rotated or elongated shapes, an oriented box encloses far less empty space than an axis-aligned one:Output:
The fit searches orientations sampled with
warp.geometry.super_fibonacci(), and the box gets tighter asnum_samplesgrows. Kernels can also callsuper_fibonacci()directly to sample rotations near-uniformly. With the defaultinclude_pca=True, results can differ in the last bits between runs. Passinclude_pca=Falsefor bitwise-reproducible boxes.warp.geometryalso adds intersection tests that can be called from kernels and from Python (#2150). They acceptwp.vec3orwp.vec3dcoordinates, return abool, and count touching as an intersection:intersect_aabb_aabb(): two axis-aligned boxes.intersect_seg_aabb(): a segment and an axis-aligned box.intersect_tri_aabb(): a triangle and an axis-aligned box.intersect_tri_tri(): two triangles, including overlap within a shared plane.intersect_seg_tri(): a segment and a triangle, including overlap within a shared plane.intersect_tri_tri_self(): two distinct triangles of one mesh, identified by their vertex indices. Contact at a shared vertex or along a shared edge does not count, and duplicate faces count as intersecting.The tests use floating-point arithmetic rather than exact predicates, so use
wp.vec3dinputs for more precision near degenerate configurations. The oriented bounding box and mesh intersection examples apply both to real meshes.Documentation
Call Warp functions from cuTile Python kernels
Important
This is an experimental feature. The API may change without a formal deprecation cycle.
Tile kernels written in cuTile Python can now use Warp's mesh, BVH, and volume queries and noise without a separate Warp launch.
warp.experimental.cutile.export_func()exports a@wp.functhat a cuTile kernel calls on tiles, once per tile element (#2346). The cuTile neural SDF example trains a neural signed-distance field with Warp mesh queries and cuTile matrix multiplies in the same kernel.The bridge is forward-only. It needs cuTile Python 1.8.1 or later and the
tileirascompiler from CUDA Toolkit 13.5. It also needs a CUDA 13 build of Warp, such as the default PyPI wheel, and a GPU with compute capability 8.0 or newer on an R580 or newer driver. The newcutileextra installs cuTile Python and the compiler components, and it can share an environment with PyTorch's CUDA 13 wheels:pip install "warp-lang[cutile]"To install the same packages explicitly:
Documentation
Array function overrides for subclasses and wrappers
A new
__warp_function__hook lets libraries that subclass or wrapwp.arraytake part in Warp's Python API, much like NumPy's__array_function__and PyTorch's__torch_function__(#1834). The class method receives supported calls that involve its arrays, such aswp.launch(),wp.copy(), andwp.clone(). It can delegate to Warp, return its own result, or returnNotImplementedto fall back to Warp's implementation.Overrides are off by default. Set
wp.config.enable_array_function_overrides = Trueat startup, before importing any library that keeps references to Warp functions. Warp functions return plainwp.arrayobjects even when their inputs are subclass instances, so the hook must convert any result that should keep the subclass type.Documentation
Other additions
wp.empty(16, dtype=float)inside a kernel creates a fixed-size local array without zero-filling it. Use it for scratch storage whose elements are written before they are read (Add awp.empty()Built-In #1073).wp.utils.array_scan()accepts a preallocatedtemp_storagebuffer, which lets scans run insidewp.capture_if()andwp.capture_while()bodies and in CUDA graphs captured outside Warp. Size the buffer withwp.utils.array_scan_temp_storage_size(), and keep it alive while any graph that captured it can still run (array_scanthat works inside conditional bodies and foreign captures (caller-provided temp storage, or a capture query) #2247).wp.capture_load()replays them. Saved graphs use.wrpformat version 20 and, as before, load only in the Warp version that saved them (fill_() and zero_() on strided and indexed arrays are rejected during CPU graph capture #2196, [BUG] bsr_compress() isn't replayed by CPU graph captures or kept in saved graphs #2272). DocumentationPerformance improvements
wp.vec4,wp.quat, and other 16-byte elements with 4-byte components. It also applies to writes ofwp.mat44,wp.spatial_vector, and other elements of 16 bytes or more. Arrays whose address or strides are not aligned, such as some PyTorch views, keep the previous element-by-element accesses, and results are the same either way. To opt out, setwp.config.enable_wide_array_access = Falsebefore kernels are first loaded ([REQ] Use 8B/16B vectorized loads in CUDA kernels for performance #712).warp.optim.linearsolvers do less redundant work per iteration on the CPU. Withuse_graph=True, they also replay their iterations from a CPU graph instead of launching each kernel from Python ([BUG] warp.optim.linear solvers are slow on CPU and ignore use_cuda_graph=True #2242).Breaking changes
Python 3.10 is no longer supported
Warp 1.20 requires Python 3.11 or newer, following the end of life of Python 3.10 on October 1, 2026 (#2128).
Removed deprecated APIs
from_environment_voxels()is removed.warp.fem.Nanogrid.from_environment_voxels()andwarp.fem.AdaptiveNanogrid.from_environment_voxels()no longer accept one array per environment or thecell_ijkskeyword. Pass onepointsarray for all environments, one environment index per point inpoint_envs, and the totalenv_count. ForAdaptiveNanogrid, also pass one refinement level per point incell_levels. Only the call shape changes: the flat form builds the same grids (Graph-capturable NanoVDB volume allocation and rebuild #1606).warp.sparse.BsrMatrix.copy_nnz_async()is removed. It only started an early transfer of the block count for a laternnz_sync()call.nnz_sync()reads the count itself, so deleting the call does not change results. Code that modifiesoffsetsdirectly should callnotify_nnz_changed()afterward ([REQ] Allocation-free path for masked sparse matrix operations #987).Build meshes and BVHs before CPU graph capture
Building a CPU
wp.Meshorwp.Bvhinside a CPU graph capture never became part of the graph: the object was built once while the graph was recorded, and every replay silently reused it. The same applied to CPU volumes allocated withwp.Volume.allocate_by_tiles()orwp.Volume.allocate_by_voxels()withoutrebuildable=True.Warp 1.20 raises
NotImplementedErrorfor these calls during CPU graph capture, so the problem surfaces instead of producing stale results (#2202). Building these objects outside a capture works as before, and CUDA graph capture is unaffected.Move construction before the capture. Inside the capture, update the object with
refit(),wp.Bvh.rebuild(), or assignments towp.Mesh.points, which CPU graph replays rerun:To allocate a volume inside a CPU capture, pass
rebuildable=Trueso that each replay rebuilds its topology from the current points. Before Warp 1.20, CPU graph replays also skipped mesh refits, mesh point and velocity assignments, and volume rebuilds. These now rerun on every launch.CPU linear solves with explicit graph capture or
check_every=0use_cuda_graph=Trueoruse_graph=Trueto awarp.optim.linearsolver now captures and replays CPU solves. In Warp 1.19 the flag had no effect on CPU. ALinearOperatoror preconditioner that computes on the host (for example with NumPy) runs only while the graph is recorded, and the solve silently returns wrong results. Passuse_graph=Falsefor these operators. The default,use_graph=None, still captures only on CUDA ([BUG] warp.optim.linear solvers are slow on CPU and ignore use_cuda_graph=True #2242).check_every=0stop at convergence and report the iterations actually performed, instead of always runningmaxiteriterations (Iterative solvers with check_every=0 run all maxiter iterations without CUDA graphs #2222).NumPy reads half-precision vector values as numbers
On Python 3.12 and later,
np.asarray()now returns numeric values for Warp vectors, matrices, quaternions, and transforms withwp.float16orwp.bfloat16components. The values come back asnp.float16andnp.float32, respectively. Previously it returned each component's 16-bit pattern as an integer, such as 15360 for 1.0 (#2104):Remove any code that decoded these integers. Python 3.11 still returns the 16-bit patterns.
bytes()andmemoryview()on objects withwp.bfloat16components now raiseBufferError, because Python's buffer protocol has no bfloat16 format. To read the raw bit patterns of a bfloat16 vectorv, copy its components into awp.bfloat16array and view it asnp.uint16:wp.array(list(v), dtype=wp.bfloat16).numpy().view(np.uint16).On all supported Python versions,
wp.array()built from a list of these objects now stores the correct values instead of the 16-bit patterns.usd-corereplacesusd-exchangeon Linux ARM64On Linux ARM64, the
examplesandbenchmarkextras now installusd-core>=26.11instead ofusd-exchange.usd-coresupports Python 3.11 through 3.14. Both packages install files intopxr, so runpip uninstall usd-exchangebefore upgrading Warp with these extras.Default CPU block size with experimental CPU blocks
With the experimental
wp.config.enable_cpu_blockssetting enabled, CPU launches that omitblock_dimnow use 256 threads per block instead of one, matching CUDA. Passblock_dim=1explicitly for kernels that expect one thread per block. The setting is off by default, and launches without it are unchanged (#2349).Notable fixes
wp.tile_mesh_query_aabb(),wp.tile_bvh_query_aabb(), andwp.tile_bvh_query_ray()could fault with illegal memory accesses, hang, or silently miss results on CUDA when a query overlapped a large part of a dense mesh or BVH. Newton hit this with meshes built withbvh_constructor="cubql"(Tiled BVH/mesh queries overflow their shared traversal stack (illegal memory access, hang, or missing results) #2181).@wp.funcwas passed to an operation that needs shared storage, such aswp.tile_broadcast(). The resulting illegal memory accesses surfaced in MuJoCo Warp's dense Hessian kernels (Kernel requests too little shared memory when it moves a tile returned by awp.functo shared storage #2294).if/elsebranches inside dynamic loops ran slower in Warp 1.18 and 1.19. A MuJoCo Warp training workload that uses depth rendering slowed down as a result (Performance regression when moving from warp 1.17 to 1.18 #2095).float32textures used more registers in Warp 1.19, most noticeably on Blackwell GPUs with compute capability 12.0. Newton's camera sensor rendering slowed down on an RTX 5090 as a result (Float texture sampling uses more registers on sm_120 since 1.19.0 #2258).Announcements
Upcoming removals
Implicit conversion of NumPy scalars and Boolean values to composite types will be removed in Warp 1.21. It has been deprecated since Warp 1.17. Kernel parameters and struct fields of vector, matrix, quaternion, or transform type still accept NumPy integer and floating-point scalars, as well as Python, NumPy, and Warp Boolean values. Warp converts them with a
DeprecationWarning. Construct the composite value explicitly instead. For awp.mat22parameter, passwp.mat22(np.float32(2.0))rather thannp.float32(2.0)(Remove implicit scalar promotion to composite types #1721).The
use_cuda_graphargument of thewarp.optim.linearsolvers will be removed in Warp 1.24. Pass the same value asuse_graph, which takes the same position. Passinguse_cuda_graphnow emits aDeprecationWarning(Deprecate use_cuda_graph in the warp.optim.linear solvers in favor of use_graph #2264).warp.build_experimentalwill be removed in Warp 1.24. Importwarp.experimental.buildinstead, which provides the sameadd_builtin()andadd_native_type()functions. New experimental modules, such aswarp.experimental.cutile, live underwarp.experimental(Move experimental APIs under awarp.experimentalnamespace #2347).Platform support
wp.tile_matmul(..., precision="tf32")also uses TF32 on GPUs with compute capability 8.0 or newer instead of falling back tofloat32.Acknowledgments
We thank the following contributors from outside the core Warp development team:
DeprecationWarningmessages emitted bywarp.init()on Python 3.14 (Python 3.14 DeprecationWarning from _pack_ without _layout_ in apic/types.py #2295).wp.float16gradients ofwp.atan2()that vanished after rescaling coordinates (float16 atan2 loses gradients after coordinate scaling #2244).wp.float64()that changed the type of a named constant for its later uses (wp.float64 / wp.int64 / wp.uint64 of a constant changes the constant's type for later uses #2351).For a complete list of changes, see the full changelog.
This discussion was created from the release v1.20.0.
All reactions