NeIO: iteration in Warp kernels, network in PyTorch

Result of the try "Warp utility + PyTorch network" for SolverNeIO in newton-neural. The change is in the upstream pull request newton-physics/newton-neural#2, head ce28f95. NVIDIA L40, Warp 1.17.0, PyTorch 2.11.0+cu128, Newton 1.8.0. 2026-12-02.

3.27x
Chain, 6 bodies: 3.03 to 0.93 ms per captured step
1.84x
Cloth, 1,089 particles: 2.18 to 1.19 ms per captured step
1.38x
Cloth, 10,201 particles: 4.87 to 3.54 ms per captured step
1.15x
Cloth, 100,489 particles: 39.06 to 34.03 ms per captured step

Main result. It works. With the default settings (tf32, compiled network) the captured step is faster on every scene measured, from 3.3 times on a small chain to 1.15 times on a cloth of 100,489 particles. The network still runs in PyTorch and still uses the tensor cores. The math did not change: each kernel agrees with the PyTorch formula it replaces to float32 rounding.

1. What was tried

2. Step time with the default settings

One captured step (CUDA graph replay) with 10 iterations, time step 1/240 s. Median of 3 alternating rounds; in each round a value is the median of 9 samples of 20 replays of a pair of steps. "Before" is the first commit of the upstream pull request, with PyTorch around the network. The last column is the earlier branch that runs the network in Warp and keeps the PyTorch operations around it.

SceneBefore: all PyTorchNow: Warp kernels + PyTorch networkGain For comparison: Warp network, PyTorch around it (fp32)
Chain, 6 bodies3.03 ms0.93 ms3.27x2.91 ms
Cloth, 1,089 particles2.18 ms1.19 ms1.84x2.47 ms
Cloth, 10,201 particles4.87 ms3.54 ms1.38x6.82 ms
Cloth, 100,489 particles39.06 ms34.03 ms1.15x54.49 ms

3. All precision settings

Captured step in ms. "Range" is the lowest and the highest round.

SceneNetwork settingBeforeRangeNowRange Gain
Chain, 6 bodiesfp323.093.09 to 3.090.980.98 to 0.993.14x
Chain, 6 bodiestf323.273.27 to 3.271.151.15 to 1.152.84x
Chain, 6 bodiestf32, compiled3.033.03 to 3.030.930.93 to 0.933.27x
Cloth, 1,089 particlesfp322.552.55 to 2.551.551.55 to 1.581.64x
Cloth, 1,089 particlestf322.362.36 to 2.371.371.37 to 1.371.73x
Cloth, 1,089 particlestf32, compiled2.182.18 to 2.181.191.18 to 1.191.84x
Cloth, 10,201 particlesfp326.276.27 to 6.284.934.93 to 4.961.27x
Cloth, 10,201 particlestf325.135.13 to 5.133.803.79 to 3.801.35x
Cloth, 10,201 particlestf32, compiled4.874.87 to 4.873.543.54 to 3.541.38x
Cloth, 100,489 particlesfp3253.1653.16 to 53.1848.2748.23 to 48.271.10x
Cloth, 100,489 particlestf3243.0543.05 to 43.0537.9537.95 to 37.961.13x
Cloth, 100,489 particlestf32, compiled39.0639.03 to 39.0834.0334.02 to 34.041.15x

4. Step time outside a capture

A step that is not replayed from a CUDA graph pays the Python cost of every launch. Default settings.

SceneBeforeRangeNowRangeGain
Chain, 6 bodies29.9 ms28.77 to 30.7810.3 ms10.07 to 10.502.90x
Cloth, 1,089 particles18.2 ms17.66 to 18.8310.4 ms10.22 to 10.431.76x
Cloth, 10,201 particles18.5 ms17.60 to 19.0810.6 ms10.33 to 10.681.74x
Cloth, 100,489 particles40.0 ms39.94 to 39.9734.6 ms34.61 to 34.651.15x

5. Is the math the same?

5.1 Each kernel against the formula it replaces

Four scenes (chain with two free boxes; chain with one step scale per articulation; cloth with a pinned edge; box on the ground with a cloth), 20 steps of 10 iterations each, CUDA and CPU. In every iteration the output of each kernel was compared with the replaced PyTorch formula on the same inputs. The value is the largest difference over all iterations, relative to the largest entry of the array.

QuantityLargest difference
Rigid: history turned with the body7e-8
Rigid: gradient in the body frame1e-7
Rigid: node inputs (with the force and torque RMS per object)2e-7
Rigid: step in the world frame1e-7
Deformable: gradient0 (bit-equal)
Deformable: node inputs (with the gradient RMS per group and the local frames)4e-7
Deformable: step in the world frame7e-6
Stored history and step scale, both optimizers0 (bit-equal to the stored inputs)

5.2 Trajectories

The iteration amplifies a rounding difference, so two runs drift apart over the steps. The test is that the kernel path drifts from the old path no more than the old path drifts from itself between CPU and CUDA. Largest difference of the positions, relative to the largest coordinate, fp32, not compiled.

Scene, after stepOld path: CPU against CUDAOld against new, CPU Old against new, CUDA
Chain with two boxes, 16e-91e-91e-10
Chain with two boxes, 208e-42e-32e-3
Chain, scale per articulation, 12e-106e-108e-10
Chain, scale per articulation, 203e-34e-31e-3
Cloth, 13e-61e-63e-6
Cloth, 202e-42e-42e-4
Box with cloth, particles, 14e-52e-69e-6
Box with cloth, particles, 202e-33e-33e-3

The old and the new path differ by the same order as the old path on two devices. I see no sign of a different method.

5.3 Tests

5.4 Two failures in the CI of the pull request, both fixed

6. What changed in the code

FileChange
newton_neural/_src/neio/optimizer_kernels.py (new, 538 lines)18 kernels and 11 functions: gradient, gradient RMS, history transport, node inputs, step, direction of the applied update, history store, carry clamp, reset.
neio/kernels.py5 kernels for the solver: two filters, the choice of the update that was not truncated, the particle displacement, the applied particle update.
neio/learned.py, rigid.py, deformable.pyiterate, commit and reset launch the kernels. The history tensors keep their names and get a Warp view of the same memory.
solvers/solver_neio.pyThe iteration has no PyTorch operation left. The two mask tensors and _pending_displacement are gone; the kernels read the mass and the flags of the model.
neio/network.py, rigid.pyRemoved: the PyTorch functions object_rms, group_rms, history_features, soft_clip and the quaternion helpers. The kernels are the one implementation.
notes/neio/neio.mdNew chapter 5: old and new, data structures, pseudo code, forks, questions.

What stays PyTorch: the network, the setup once per model, the checkpoint loading, the first-call check.

7. Decisions for you

#QuestionAs builtOther option
1Who owns the history arrays?PyTorch tensors own the memory and the kernels take Warp views. The attribute names stay as they were.Warp arrays of the optimizer own it and the network takes tensor views, as a Newton solver holds its arrays. Same speed.
2Is the step outside a capture important?Plain wp.launch, one kernel per formula (11 launches for a body iteration), as SolverVBD launches.Recorded launches and fused kernels for small scenes, as the port. Faster outside a capture, more code, and not the way SolverVBD launches.
3Result type of iterate for an own optimizer of a userA contiguous float32 tensor on the device of the model. The solver reads it through a Warp view.Convert any tensor first, at the cost of a PyTorch operation.
4The pull request in your fork with the Warp network backend (WarpInference)It is stacked on the branch of the upstream PR, which now holds the kernels. It touches the same files and needs a rebase.Rebase it onto the kernels and keep it as an option for a step with no PyTorch operation, or close it. On the scenes measured it is slower than the default at every size.

8. Limits

9. Links