We saw the same thing w.r.t. matrix multiply in that
naively calling Eigen was about the same speed or even
a bit faster than our custom approach, but the custom
approach uses far less memory.
My suspicion is that Eigen's maintaining memory
locality better than we are and that we're spending all
the time in our algorithm pulling from memory to CPU.
This is reinforced by the fact that CppAD, which is normally
slow compared to the other autodiff algorithms is very fast
in this case relative to everything but Stan, and CppAD is
the only other package with the traits defined to tell Eigen
the sizes of autodiff variables so that it can sort out blocking
for memory locality efficiently.
I believe Marcus already had the Giles-style matrix derivatives
for left and right division.
If I understand, there are three systems in play:
1. naive autodiff of Eigen's LLT
2. analytic scalar diff (cholesky_decompose.hpp)
3. analytic matrix diff (cholesky_decompose_eigen.hpp)
* 1 and 2 have the same speed, but 3 is 5x slower.
* 2 and 3 use the same amount of memory, but 1 uses 10x as much.
For an N x N matrix, the amount of memory to store the expression
graph for approach 1 grows as O(N^3). Can it be kept
to O(N^2) for 2 and 3? Peak memory usage is going to be determined
by the LLT algorithm --- is that O(N^2) or O(N^3)? Of course, time's
going to hit O(N^3) whatever we do.
And keep in mind that a huge advantage of doing all of our ops
as doubles is that we can speed things up with GPUs, etc. I
think Eigen's planing around with CUDA implementations.
- Bob
> --
> You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
stan-dev+u...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.
> <cholesky_decompose_eigen.hpp><cholesky_decompose.hpp>