Warp

Follow particle arrays from a Python launch through CUDA kernels to simulation and viewer outputs.

Warp compiles numerical Python kernels to code that runs in parallel on CPUs or CUDA GPUs. It supplies arrays, geometric operations and automatic differentiation that simulation projects can use to implement their own computations.

How does Python move thousands of particles on a GPU?

How the data moves
  1. InputPrepare arraysparticle positions + velocities

    Store one position and velocity per particle.

  2. ProcessLaunch GPU kernelsspatial grid → contacts → integration

    Find nearby particles and compute the next state.

  3. OutputMeasure and drawfull arrays + sampled viewport

    The viewer draws a subset and the script reports all-particle statistics.

Dispatch a kernel from Python

Python prepares the arrays and dispatches work. A Warp kernel performs per-particle work in parallel on the GPU. The DEM example searches a spatial grid for neighbors, computes contact forces, and advances position and velocity.

Read the full array and the viewer sample

The recorded GPU run computes 65536 particles and displays 16384. The complete position array has shape [65536, 3], and the viewer selects one of every four rows with points[::4]. Keep that distinction when interpreting simulation counts and viewport performance. Official Warp DEM code · Particle lab

Warp 1.19

Warp 1.19.0 adds reusable sparse-matrix assembly, new sparse preconditioners, Surface Nets mesh extraction, and experimental gradients for texture sampling. Reusable assembly helps when a finite-element solve repeatedly changes coefficients while keeping the same sparsity pattern. Isaac Lab 3.0 and Isaac Sim 6.2 target Warp 1.17.0. Warp 1.19.0 release · Isaac Lab 3.0 release · Isaac Sim 6.2 release notes

Architecture

Component Responsibility and data boundary
@wp.kernel / wp.launch A kernel defines work for a logical thread. The launch sets the iteration dimensions and passes typed arrays and parameters.
Compilation and cache Warp lowers a Python module’s kernels and functions to native code for the selected target. Its module cache avoids repeating the same compilation.
wp.array / interop Host code allocates the arrays and chooses placement. The Warp/PyTorch bridge can share compatible memory, so device placement and synchronization matter when one framework hands off a buffer.
wp.Tape Tape records differentiable kernel launches and references to arrays. Backward launches use the required forward values and accumulate gradients in gradient buffers.

Guide diagram based on the official references below.

Mermaid
flowchart LR
    p["Typed Python kernels"]
    c["Module compilation and cache"]
    a["Device arrays"]
    k["Parallel forward launches"]
    loss["Scalar loss"]
    t["Tape and adjoint kernels"]
    g["Input gradients"]
    p --> c
    c --> k
    a --> k
    k --> loss
    k --> t
    loss --> t
    t --> g

Official figures and examples

Warp’s compiler pipeline shows how kernel declarations become device code. The Python application controls allocation and launch.

Warp’s compiler pipeline shows how kernel declarations become device code. The Python application controls allocation and launch. Original figure and context

The Tape diagram distinguishes forward kernel launches and the reverse pass used to propagate gradients.

The Tape diagram distinguishes forward kernel launches and the reverse pass used to propagate gradients. Original figure and context

Walkthrough

  1. For a spring parameter fit, allocate arrays for initial positions, velocities, and stiffness. Write one kernel to advance the state and another to compare the predicted endpoint with an observed endpoint.
  2. Run the launch sequence inside a wp.Tape, keep the state values required by backward launches, and call backward on the loss. Feed the stiffness gradient to the optimizer.
  3. Benchmark steady-state execution after a warmup that includes first-use compilation. For repeated launch graphs, evaluate the graph capture and replay API once data flow and device placement are stable.

Validation

  • Tape references arrays rather than storing every value they held. Keep separate states or use checkpointing when an iterative kernel overwrites values needed for backward computation.
  • On a small problem, compare the computed gradient with finite differences before increasing rollout length or using a GPU graph.

License and scope

Warp uses Apache-2.0. Runtime and GPU requirements depend on the release. Warp 1.19 LICENSE

Newton · MuJoCo Warp

Official references