VoroPlex: A Python Framework for Multi-Threaded and Differentiable Voronoi Tessellation

Peihang Lin, Shanmei Wanyan, Mucheng Zhu, Ying Jiang, Chris H. Rycroft, Chenfanfu Jiang, Jiayin LuarXiv 2026

TL;DR

Voronoi tessellations—nature’s favorite way to partition space, seen everywhere from soap bubbles to cosmic voids—are notoriously slow to compute in Python and difficult to optimize directly. VoroPlex bridges a fast, multi-threaded C++ engine directly into PyTorch, making 2D and 3D Voronoi cells both massively parallel and fully differentiable. Whether you are building adaptive simulation meshes or inverse-designing custom cellular foams, you can now optimize point placements using standard gradient descent up to 46x faster than SciPy.

What Problem Does This Paper Address?

Imagine scattering a handful of "generator" points across space and claiming for each point all the territory closer to it than to any neighbor. The resulting mosaic of polygons (in 2D) or polyhedra (in 3D) is a Voronoi tessellation. Scientists use them constantly to measure atomic packing, model polycrystalline grains, and construct simulation meshes.

(Correction: Let's look at the actual geometry) Voronoi tessellations in 2D and 3D, alongside a regularized Centroidal Voronoi Tessellation.

If you work in Python, however, you hit two walls. First, existing Python Voronoi tools run on a single CPU thread, bogging down when systems scale to millions of particles. Second, they treat the tessellation as a static geometric output rather than a differentiable function. If you want to nudge your generator points to achieve a specific outcome—say, aligning cell walls to make a stiffer 3D-printed foam—working out the gradients by hand is a mathematical nightmare because moving a single point shifts the boundaries of all its neighbors.

Methods

VoroPlex solves the speed bottleneck by wrapping the multi-threaded C++ library Voro++ via Cython and OpenMP. Instead of computing a massive global triangulation all at once (like SciPy's Qhull backend), Voro++ computes each cell independently: it starts with a bounding box and repeatedly slices it with perpendicular bisector planes from nearby neighbors. Because cells don't depend on one another during construction, threads can chew through them in parallel. VoroPlex also supports radical (or power) tessellations, which weight points by radii to handle particles of different sizes without slicing through them.

Figure 2: Computing a Voronoi cell separately. (a) The cell of a generator (purple) starts as the whole domain. (b) The cell is cut by the perpendicular bisector between the generator and a neighboring generator (gray). (c) Further cuts by other neighbors produce the final cell. (d) Since each cell is computed separately, many cells can be computed in parallel.

What is newly introduced on top of this parallel backend is analytical differentiability wired into PyTorch:

  • Vertex Signatures: As Voro++ builds each cell, VoroPlex labels every vertex with a "signature"—the integer IDs of the $d+1$ generators (or domain walls) equidistant from it.
  • Custom Backward Pass: Because a vertex is equidistant from its defining generators, its coordinates are the solution to a tiny $2\times2$ or $3\times3$ linear system. During backpropagation, PyTorch computes how your custom loss changes with respect to the vertex positions, and VoroPlex uses explicit analytical formulas on those signatures to pass gradients back to the generator positions (and radii).
  • Three Representations: Users can request raw geometry (fastest, for analysis), per-cell vertices with signatures (for differentiation without needing to stitch cells together), or topology (which deduplicates vertices via integer signatures to extract shared interface meshes).

Datasets

Not discussed in the paper. Because VoroPlex is a computational geometry framework rather than a machine-learning model, the authors evaluate it using synthetic benchmarks: uniform random generator distributions ($10^4$ to $10^7$ points in 2D squares and 3D cubes) and analytical mathematical functions—such as Gaussian density fields, 2D signed distance functions (circles, stars, flowers, hearts), and target fabric tensors.

Key Insights and Ideas

  • Bypassing floating-pointstitching headaches: When cells are computed independently in floating-point arithmetic, nearly degenerate points can cause two neighbors to slightly disagree on tiny edges or faces. In VoroPlex's per-cell differentiable mode, each cell keeps its own copy of its vertices. During the backward pass, gradient contributions from shared vertices simply add up—meaning you get exact, valid gradients for cell geometry without ever needing a fragile mesh-stitching step.
  • Topology changes don't break gradient descent: Moving generators continuously eventually causes discrete topological flips (cells gaining or losing neighbors). By recomputing the tessellation in parallel at every step and differentiating the current linear system of each vertex, standard optimizers like Adam smoothly navigate across topological transitions.
  • Vectorized flat arrays beat Python objects: Previous Voro++ wrappers (pyvoro) consumed ~230 KiB per cell by copying C++ objects into Python dictionaries. Packing all cells into flat, read-only NumPy arrays cuts memory dramatically and keeps Python loop overhead to ~2% of core time.

Key Results

  • Speedups: For $10^6$ points on 28 CPU threads, VoroPlex computes tessellations in 0.295 s (2D) and 1.47 s (3D)—making it 46x faster than SciPy in 2D and 39x faster in 3D (and up to 90x faster than single-threaded pyvoro, which needed over 213 GiB of RAM). Even on a single thread, VoroPlex beats SciPy by 4.4–5.2x in 2D and ~2x in 3D.
  • Parallel Scaling: The core cell-computation loop hits an adjusted parallel efficiency of 0.96 in 3D and 0.91 in 2D across 28 cores.
  • Inverse Design & Meshing: The authors demonstrate three end-to-end differentiable applications using Adam:
  • Density-weighted Centroidal Voronoi Tessellations (CVTs) that smoothly cluster cells along thin 2D curves or 3D cube edges.
  • 2D Shape Meshing where interfaces between inner and outer cells snap cleanly onto zero-contours of Signed Distance Functions.
  • Anisotropic Foam Design, optimizing 3D cell wall normals to match target fabric tensors (lamellar plates, vertical columns, and radial slats), raising principal-axis alignment from random (~0.32) to >0.99.

Limitations and Future Work

  • Serial Memory Bottlenecks: While cell computation scales nearly ideally, overall 28-thread efficiency for a full call drops to 0.78 in 3D and 0.37 in 2D due to single-threaded C++ steps—specifically allocating and freeing Voro++ container blocks. Reusing containers across optimization steps or parallelizing allocation could remove this bottleneck.
  • CPU–GPU Data Transfers: Both Voro++ tessellation and the analytical vertex-derivative step run on the CPU. When PyTorch evaluates losses on a GPU, copying gradients back and forth slows the backward pass (88 ms on GPU vs. 33 ms on CPU for $10^5$ 3D points), and GPU VRAM caps problem sizes around $5\times 10^5$ 3D cells on an 11 GiB card. Moving vertex derivatives—and eventually tessellation itself—onto the GPU is a key target for future work.
  • Local Minima in Stiff Geometries: In 3D columnar foam optimization, gradient descent aligned cell axes well ($M=0.992$) but could not drive vertical wall tilt all the way to zero, as doing so requires large, coordinated rearrangements of generators.

Summary updated

BibTeX
@misc{lin2026voroplex,
  author = {Peihang Lin and Shanmei Wanyan and Mucheng Zhu and Ying Jiang and Chris H. Rycroft and Chenfanfu Jiang and Jiayin Lu},
  title = {{VoroPlex: A Python Framework for Multi-Threaded and Differentiable Voronoi Tessellation}},
  year = {2026},
  eprint = {2611.33829},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.33829},
}
Figure