Retrieved article excerpt
Open article · Retrieved 2026-10-30T14:24:44.920970+00:00
[← Tesseract Blog](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/blog/)
2026-10-25 · [@dionhaefner](https://github.com/dionhaefner)
# Fast, GPU-native differentiable physics and beyond with Tesseract[¶](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/blog/2026-10-25-gpu-native-interop/#fast-gpu-native-differentiable-physics-and-beyond-with-tesseract "Link to this heading")
Tesseract lets you put a differentiable physics simulation inside a JAX or PyTorch training loop. Paired with [Tesseract-JAX](https://github.com/pasteurlabs/tesseract-jax) and [Tesseract-Torch](https://github.com/pasteurlabs/tesseract-torch), the simulator runs in its own process or container, while the training loop treats it like any other differentiable function. Until now, every GPU array passed into or out of a Tesseract was copied through host memory, which for large arrays can take longer than the computation itself. The new [GPU transport](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/content/how-to/gpu-transport/) removes this detour, so arrays stay on the GPU the whole way. This post shows what that unlocks on a real application, how to turn it on, and what happens under the hood when passing GPU memory up and down the call stack (and over HTTP between processes).
Two panels comparing how a GPU array, drawn as a heatmap tile of a temperature field, reaches a Tesseract in another process. Each panel has a host memory lane per process, split by the process boundary, above one GPU memory lane that spans both processes. In the top panel, the default path, the array is copied up from the GPU into the training process's host memory, encoded into a long band of base64 text that crosses the boundary over HTTP, decoded in the solver's host memory, and copied back down onto the GPU. A label notes that a 3.84 MB array becomes 5.1 million characters of base64. In the bottom panel, labeled gpu\_transport equals cuda\_ipc, the host memory lanes are empty except for one short handle string crossing over HTTP, while the array moves straight across the GPU lane in a device-to-device copy.
Two ways a GPU array travels to a Tesseract in another process. Through the host, every byte leaves the GPU and is encoded as text. With `cuda_ipc`, only a handle is sent via HTTP, and outputs are returned the same way.[¶](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/blog/2026-10-25-gpu-native-interop/#id1 "Link to this image")
## The problem[¶](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/blog/2026-10-25-gpu-native-interop/#the-problem "Link to this heading")
It all started with the winning entry of our first hackathon, [Multi-Agent-DPC](https://github.com/SOLARIS-JHU/Multi-Agent-DPC) by Pietro Zanotta, Dibakar Roy, and Honghui Zheng, which later grew into the ICML 2026 paper [CINOC](https://arxiv.org/abs/2605.25867). It learns an optimal control policy for a swarm of mobile heaters that shape the temperature along a rod. The policy is a small neural network that decides how hard each heater heats or cools and where it moves, and it is trained by backpropagating through 300 steps of a differentiable PDE solver. The team wrapped the solver as a Tesseract and called it from their JAX training loop through Tesseract-JAX.
Left, the problem: a plot of temperature along a rod. The starting profile is a tall hump in the middle, the target is a dashed curve that is warm on the left and cold on the right, and faded curves show the profile moving from one to the other until, after 300 steps, it lies on the target. Below the plot, the rod is drawn colored by its starting temperature, with eight heaters under it: one heating near the left end and seven cooling, with arrows showing the outer heaters drifting outward. A dashed pink frame around the heaters is labeled learned: how hard each heater heats or cools, and where it moves. Right, two boxes. The training process box, with the JAX logo, samples 32 random rods with a start and a target each, computes a loss for missing the target plus penalties, and uses jax.grad and an Adam step to update the policy's 11,298 weights. The Tesseract box, solverHeat\_decentralized, loops 300 times through a policy network in which each heater sees the error near it, the heaters heating and moving, and one Crank–Nicolson step of the heat equation. Between the boxes, the apply endpoint takes the weights, starts, and targets down and returns the trajectories, with z\_trajectory shaped 32 by 300 by 100, and the vector\_jacobian\_product endpoint takes the gradient of the loss with respect to the trajectories down and returns the gradient with respect to the weights.
Left, one Multi-Agent-DPC task, solved with the team’s trained policy. The policy decides how each of the eight heaters heats, cools, and moves. Over 300 steps it drives the rod from its starting temperature (gray) onto the target (dashed). Right, one training step. The training loop samples 32 rods and calls the solver Tesseract twice, through `apply` for the trajectories and through `vector_jacobian_product` for the gradient with respect to the policy’s weights.[¶](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/blog/2026-10-25-gpu-native-interop/#id2 "Link to this image")
It worked but was too slow to train with, so the team’s training script ended up calling the solver directly with the Tesseract path switched off. They published a [branch that reproduces the slowdown](https://github.com/SOLARIS-JHU/Multi-Agent-DPC/tree/repro-performance-issue), and over the following months we used it as a benchmark to make Tesseract faster for differentiable physics applications, one release at a time.
A deeper problem was the data communication overhead. Each array left the GPU, was encoded as text into a JSON body, sent over HTTP, and was decoded and copied back onto the GPU on the other side, once for the forward pass and once for the gradient. Through that path, running the solver on the GPU gained so little that it was faster to run it on CPU instead.
With the new GPU transport capabilities in Tesseract Core (`v1.15.0`), Tesseract-JAX (`v0.5.0`), and Tesseract-Torch (`v0.2.0`), arrays now stay where they are. Only a 64-byte handle is sent across the process boundary, and the data moves only within the memory of the GPU, which is shared by both processes. Together with better batching support and a cache for the solver’s forward pass, this brings Multi-Agent-DPC’s training step within 20% of importing the solver directly. For the much larger arrays common in 3D simulation, transport is now two orders of magnitude faster than the trip through host memory.
Why not just import the solver?
If you can import a component, import it. The Multi-Agent-DPC team came to the same conclusion, and the code for CINOC imports its solvers directly.
But often you can’t. Many entries to this year’s [Tesseract Hackathon](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/blog/2026-09-30-tesseract-hackathon-winners/) were built around components that did not want to be imported into Python directly. [δSnowSac](https://github.com/kasProg/dSnowSac) trains a PyTorch network through NOAA’s Fortran streamflow models, [PRISMO](https://github.com/benvial/prismo) takes one JAX gradient through a Julia semiconductor solver and a FEniCS optics solver, and [Differentiable Silicon](https://github.com/hozaifa1/differentiable-silicon) dispatches to a proprietary TCAD binary over SSH. [Mosaic](https://github.com/pasteurlabs/mosaic) puts solvers from deal.II and OpenFOAM to JAX-FEM and XLB behind the same Tesseract interface, each with its own dependencies. Tesseract puts such a component in its own process or container and still allows it to participate in differentiable pipelines. See also [When to use Tesseract](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/content/concepts/when-to-use/).
## A faster, GPU-native Multi-Agent-DPC[¶](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/blog/2026-10-25-gpu-native-interop/#a-faster-gpu-native-multi-agent-dpc "Link to this heading")
Let’s turn on GPU transport for the Multi-Agent-DPC training loss, with the solver served from the team’s [`tesseract_api.py`](https://github.com/dionhaefner/Multi-Agent-DPC/blob/dca8d074eacc9ea97a1cd43740f115340c437dff/tesseracts/solverHeat_decentralized/tesseract_api.py). Passing `gpu_transport="cuda_ipc"` to the `Tesseract` constructor is all you need (see also [Keep GPU arrays on the device with cuda\_ipc](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/content/how-to/gpu-transport/)), and Tesseract-JAX picks it up from there:
```
import os
# NEW: two JAX processes now share one GPU, so neither should claim 75% of it at startup.
os.environ["XLA_PYTHON_CLIENT_PREALLOCATE"] = "false"
import jax
from jax.flatten_util import ravel_pytree
from tesseract_core import Tesseract
from tesseract_jax import apply_tesseract
solver = Tesseract.from_source(
"tesseracts/solverHeat_decentralized/tesseract_api.py",
gpu_transport="cuda_ipc", # NEW: pass GPU arrays by handle (2)
)
def loss(params, z_init, xi_init, z_target):
inputs = {
"z_init": z_init,
"xi_init": xi_init,
"z_target": z_target,
"flat_params": ravel_pytree(params)[0],
}
# NEW: one call for the whole batch instead of one per rollout (1)
traj = apply_tesseract(solver, inputs, vmap_method="broadcast_all")
return tracking_error(traj["z_trajectory"], z_target) + penalties(traj)
def batch_loss(params, z_init, xi_init, z_target):
losses = jax.vmap(loss, in_axes=(None, 0, 0, 0))(params, z_init, xi_init, z_target)
return losses.mean()
with solver:
grads = jax.jit(jax.grad(batch_loss))(params, z_init, xi_init, z_target)
```
This deviates from the original script in two ways:
1. `apply_tesseract(..., vmap_method="broadcast_all")` sends the whole batch of rollouts to the Tesseract as one call, which the solver supports by accepting an optional leading batch dimension.
2. `Tesseract.from_source(..., gpu_transport="cuda_ipc")` enables the GPU transport for a source-built Tesseract (a containerized Tesseract works the same way through `Tesseract.from_image(..., gpus=["all"], gpu_transport="cuda_ipc")`).
For applications that use torch instead of JAX, Tesseract-Torch works in exactly the same way with an identical `apply_tesseract` function.
## Turns out it’s pretty good[¶](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/blog/2026-10-25-gpu-native-interop/#turns-out-it-s-pretty-good "Link to this heading")
Here is one training step of Multi-Agent-DPC, that is, a batch of 32 rollouts forwards and backwards, as it went from the team’s setup to the GPU path ([benchmark script](https://github.com/dionhaefner/Multi-Agent-DPC/blob/dca8d074eacc9ea97a1cd43740f115340c437dff/examples/heat1d/decentralized/benchmark.py)):
| Setup | Time per training step |
| --- | --- |
| The original setup, on current Tesseract releases | 1.5 s |
| Batched, solver on the GPU, arrays through host memory | 261 ms |
| Same, with `cuda_ipc` | 209 ms |
| Same, with the solver’s VJP cache | 127 ms |
| Solver imported directly, one process (baseline) | 106 ms |
The GPU transport removes the trip through host memory, which saves about 50 ms per step. The [`VJP cache`](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/content/reference/tesseract-runtime-api/#tesseract_core.runtime.experimental.set_jax_vjp_cache_size "tesseract_core.runtime.experimental.set_jax_vjp_cache_size"), an experimental option in Tesseract’s JAX recipe, saves another 80 ms by keeping the residuals of the forward pass, so the gradient call doesn’t rerun all 300 steps. What remains, about 20 ms per step, is mostly the fixed cost of two HTTP requests and the handle exchange.
A Multi-Agent-DPC call moves about 4.8 MB in and out combined, which is modest. How much the transport matters depends mostly on