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.
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.
tf32, fp16, bf16 and compile work
as before, and the first-call check is the same.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.
| Scene | Before: all PyTorch | Now: Warp kernels + PyTorch network | Gain | For comparison: Warp network, PyTorch around it (fp32) |
|---|---|---|---|---|
| Chain, 6 bodies | 3.03 ms | 0.93 ms | 3.27x | 2.91 ms |
| Cloth, 1,089 particles | 2.18 ms | 1.19 ms | 1.84x | 2.47 ms |
| Cloth, 10,201 particles | 4.87 ms | 3.54 ms | 1.38x | 6.82 ms |
| Cloth, 100,489 particles | 39.06 ms | 34.03 ms | 1.15x | 54.49 ms |
Captured step in ms. "Range" is the lowest and the highest round.
| Scene | Network setting | Before | Range | Now | Range | Gain |
|---|---|---|---|---|---|---|
| Chain, 6 bodies | fp32 | 3.09 | 3.09 to 3.09 | 0.98 | 0.98 to 0.99 | 3.14x |
| Chain, 6 bodies | tf32 | 3.27 | 3.27 to 3.27 | 1.15 | 1.15 to 1.15 | 2.84x |
| Chain, 6 bodies | tf32, compiled | 3.03 | 3.03 to 3.03 | 0.93 | 0.93 to 0.93 | 3.27x |
| Cloth, 1,089 particles | fp32 | 2.55 | 2.55 to 2.55 | 1.55 | 1.55 to 1.58 | 1.64x |
| Cloth, 1,089 particles | tf32 | 2.36 | 2.36 to 2.37 | 1.37 | 1.37 to 1.37 | 1.73x |
| Cloth, 1,089 particles | tf32, compiled | 2.18 | 2.18 to 2.18 | 1.19 | 1.18 to 1.19 | 1.84x |
| Cloth, 10,201 particles | fp32 | 6.27 | 6.27 to 6.28 | 4.93 | 4.93 to 4.96 | 1.27x |
| Cloth, 10,201 particles | tf32 | 5.13 | 5.13 to 5.13 | 3.80 | 3.79 to 3.80 | 1.35x |
| Cloth, 10,201 particles | tf32, compiled | 4.87 | 4.87 to 4.87 | 3.54 | 3.54 to 3.54 | 1.38x |
| Cloth, 100,489 particles | fp32 | 53.16 | 53.16 to 53.18 | 48.27 | 48.23 to 48.27 | 1.10x |
| Cloth, 100,489 particles | tf32 | 43.05 | 43.05 to 43.05 | 37.95 | 37.95 to 37.96 | 1.13x |
| Cloth, 100,489 particles | tf32, compiled | 39.06 | 39.03 to 39.08 | 34.03 | 34.02 to 34.04 | 1.15x |
A step that is not replayed from a CUDA graph pays the Python cost of every launch. Default settings.
| Scene | Before | Range | Now | Range | Gain |
|---|---|---|---|---|---|
| Chain, 6 bodies | 29.9 ms | 28.77 to 30.78 | 10.3 ms | 10.07 to 10.50 | 2.90x |
| Cloth, 1,089 particles | 18.2 ms | 17.66 to 18.83 | 10.4 ms | 10.22 to 10.43 | 1.76x |
| Cloth, 10,201 particles | 18.5 ms | 17.60 to 19.08 | 10.6 ms | 10.33 to 10.68 | 1.74x |
| Cloth, 100,489 particles | 40.0 ms | 39.94 to 39.97 | 34.6 ms | 34.61 to 34.65 | 1.15x |
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.
| Quantity | Largest difference |
|---|---|
| Rigid: history turned with the body | 7e-8 |
| Rigid: gradient in the body frame | 1e-7 |
| Rigid: node inputs (with the force and torque RMS per object) | 2e-7 |
| Rigid: step in the world frame | 1e-7 |
| Deformable: gradient | 0 (bit-equal) |
| Deformable: node inputs (with the gradient RMS per group and the local frames) | 4e-7 |
| Deformable: step in the world frame | 7e-6 |
| Stored history and step scale, both optimizers | 0 (bit-equal to the stored inputs) |
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 step | Old path: CPU against CUDA | Old against new, CPU | Old against new, CUDA |
|---|---|---|---|
| Chain with two boxes, 1 | 6e-9 | 1e-9 | 1e-10 |
| Chain with two boxes, 20 | 8e-4 | 2e-3 | 2e-3 |
| Chain, scale per articulation, 1 | 2e-10 | 6e-10 | 8e-10 |
| Chain, scale per articulation, 20 | 3e-3 | 4e-3 | 1e-3 |
| Cloth, 1 | 3e-6 | 1e-6 | 3e-6 |
| Cloth, 20 | 2e-4 | 2e-4 | 2e-4 |
| Box with cloth, particles, 1 | 4e-5 | 2e-6 | 9e-6 |
| Box with cloth, particles, 20 | 2e-3 | 3e-3 | 3e-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.
ce28f95), L40: 853 tests in 1482 s, 1 skipped,
1 failure. The failure is test_compiled_loss_under_either_autocast_type_cuda of the host, which also fails on
main on this machine.test_distance_joint_holds_a_body_cpu failed on the first head. Cause: my test, not the solver. Its helper ran
forward kinematics with the default joint coordinates, which puts both linked boxes on their anchors. So the test simulated a box
that falls 0.3 m and is caught, and the result depended on the arithmetic of the machine. From the poses of the scene both joints
stay within 0.28 mm of their length on CPU and CUDA. The test now asks 1 mm in every step.test_no_kernel_compiles_an_adjoint failed on the head with the kernels. The host compiles no kernel with a backward
pass, and the new kernel module did not switch it off. One line fixes it; the step times are the same with it.| File | Change |
|---|---|
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.py | 5 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.py | iterate,
commit and reset launch the kernels. The history tensors keep their names and get a Warp view of the same
memory. |
solvers/solver_neio.py | The 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.py | Removed: the PyTorch functions object_rms,
group_rms, history_features, soft_clip and the quaternion helpers. The kernels are the one
implementation. |
notes/neio/neio.md | New 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.
| # | Question | As built | Other option |
|---|---|---|---|
| 1 | Who 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. |
| 2 | Is 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. |
| 3 | Result type of iterate for an own optimizer of a user | A 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. |
| 4 | The 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. |
index_add_ on
CUDA has the same property.notes/neio/neio.md, chapter 5, on the local work branch ankac/neio-warp-kernels
(the upstream pull request has the code without the notes).