scikit-cuda icon indicating copy to clipboard operation
scikit-cuda copied to clipboard

CUSOLVER for linalg routines

Open guillochon opened this issue 8 years ago • 17 comments

As the CULA library is effectively abandonware for the Mac (the free version links are broken and haven't been updated in 4 years), it is critical to have CUSOLVER working for all functions in order for skcuda to be useful on OS X.

Here's a running list of functions that should have the CUSOLVER option available within linalg that I believe currently don't:

  • [x] cho_solve
  • [x] inv
  • [x] qr
  • [ ] eig (partially implemented)
  • [ ] dmd

guillochon avatar May 02 '17 00:05 guillochon

svd and pinv already have cusolver support in the latest GitHub revision. eig has cusolver support when the input is symmetric/Hermitian.

lebedov avatar May 02 '17 00:05 lebedov

Ah, should the svd and pinv tests be enabled then for cusolver?

guillochon avatar May 02 '17 00:05 guillochon

There already are unit tests in place for svd/pinv cusolver support, e.g., here and here.

lebedov avatar May 02 '17 00:05 lebedov

cho_factor contains cusolver support.

lebedov avatar May 18 '17 02:05 lebedov

Oh great! For me at least, the one remaining function that would be great to have is cho_solve. Also inv seems like it should be higher priority.

guillochon avatar May 18 '17 12:05 guillochon

cho_solve now contains cusolver support.

lebedov avatar May 28 '17 20:05 lebedov

inv now contains cusolver support.

lebedov avatar May 29 '17 00:05 lebedov

qr now contains cusolver support.

lebedov avatar Jun 25 '17 18:06 lebedov

@lebedov Hi, does there exist any interface of cusolver for solving the linear system Ax=b where A is already upper or lower triangular (e.g. does not need the be factored). That is if we want to solve the system A^{-1/2} x = b and we already have L=A^{1/2} is there any interface to directly solve the system without going to factor L further?

botev avatar Jul 19 '17 06:07 botev

@botev, the cusolver*potrs and cusolver*getrs functions can be used to solve systems that have already been factorized with Cholesky or LU decomposition, respectively (the former is utilized in the cho_solve function, while the latter is used in the inv function). LAPACK does have a function for solving triangular systems (*tptrs), but I'm not aware of an equivalent in CUSOLVER.

lebedov avatar Jul 19 '17 15:07 lebedov

@lebedov So if I follow correctly the cusovler code for solving A^{-1} x = b where A is symmetric it proceeds like this:

  1. Use DnSpotrf to find L such that LL^T = A
  2. Use DnSpotrs to solve (LL^T)^{-1}x = b

In my case, however, I want to solve L^{-1}x = b where L is lower triangular, however, note that this is not the factorization of the matrix I want to inverse, but the actual matrix. If I understand correctly this currently does not have a specialised procedure but one has to apply the same two steps?

botev avatar Jul 19 '17 18:07 botev

@botev Right - I'm not aware of a specialized CUSOLVER procedure when the actual matrix is triangular.

lebedov avatar Jul 19 '17 18:07 lebedov

Thanks a lot for the clarification.

botev avatar Jul 19 '17 18:07 botev

@lebedov What about this - http://scikit-cuda.readthedocs.io/en/latest/generated/skcuda.cublas.cublasStrsm.html isn't that exactly for solving L^{-1} x = b?

botev avatar Jul 19 '17 23:07 botev

@botev You're right - I haven't tried it, but it looks like it will do the trick.

lebedov avatar Jul 19 '17 23:07 lebedov

@lebedov Seems like eig doesn't work for complex (Hermitian) input

Randl avatar Aug 11 '18 17:08 Randl

@Randl can you provide an example? The unit test for Hermitian input using the CUSOLVER backend seems to pass in the latest revision.

lebedov avatar Sep 04 '18 01:09 lebedov