I've been working on the allocation and registration cost of scalar autodiff records produced by Matrix<var> arithmetic. The idea is to allocate output records together and register one span, while keeping the existing expression interface.
The PR on my Math fork covers addition, subtraction, division, elementwise multiplication, and matrix multiplication. It also updates adjoint reset, nested recovery, and profiling to account for the spans.
An earlier hier_2pl benchmark showed 5–7% less wall time and 17.8% fewer whole-run instructions. The current version passes 39 focused tests, including nested memory lifetimes, repeated gradients, empty matrices, and mixed storage orders.
Would this approach be worth bringing upstream? I could start with the allocation/lifecycle support and one operation if you'd prefer a smaller first PR.
I've been working on the allocation and registration cost of scalar autodiff records produced by
Matrix<var>arithmetic. The idea is to allocate output records together and register one span, while keeping the existing expression interface.The PR on my Math fork covers addition, subtraction, division, elementwise multiplication, and matrix multiplication. It also updates adjoint reset, nested recovery, and profiling to account for the spans.
An earlier
hier_2plbenchmark showed 5–7% less wall time and 17.8% fewer whole-run instructions. The current version passes 39 focused tests, including nested memory lifetimes, repeated gradients, empty matrices, and mixed storage orders.Would this approach be worth bringing upstream? I could start with the allocation/lifecycle support and one operation if you'd prefer a smaller first PR.