Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add solve and svn to dispatched function #2002

Merged
merged 6 commits into from Dec 2, 2022

Conversation

Ericgig
Copy link
Member

@Ericgig Ericgig commented Sep 29, 2022

Description
Add data layer functions needed to update steadystate to use qutip's data layer.

Most of steadystate's methods solve the system L(rho_ss) = 0 using different solver from numpy, scipy, mkl.
This add the solve dispatched function to wraps this operation at the data layer level.
For the CSR version, it gives access to all methods available in scipy.sparse.linalg and our mkl version.
For the Dense version, solve and lstsq from numpy.linalg are made available.
Options supported by numpy / scipy for each function are pass through:
qutip.data.solve(A, B, method, options) call scipy.sparse.linalg.method(A, B, **options).

Other methods of steadystate decompose the Liouvillian with either eigen or svd.
svd was added as a dispatched function, but only with specialization for Dense.
I made a sparse version, but svds can't readily compute all singular values and does not respond well to splitting the problem into 2 like it was done for sparse eigensolver.

This PR only include the new dispatched functions, not updated steadystate using them or Qobj interface.

Copy link
Contributor

@hodgestar hodgestar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think allowing specializing solving and SVD is extremely useful. I have a few questions though:

  • Do you have a specific use case that you're adding it for right now?
  • It will be hard to support methods such as "mkl_spsolve" on a strange data backend, so essentially inside qutip itself it is not okay to pass a method except when it was supplied to us by the user. Do you have any idea how to ensure we don't forget that rule? Or any ideas on how to provide an interface that allows specifying a method but which also doesn't break if someone hardcodes a method name in a place that is difficult for users to override?

qutip/core/data/eigen.py Outdated Show resolved Hide resolved
Co-authored-by: Simon Cross <hodgestar+github@gmail.com>
@Ericgig
Copy link
Member Author

Ericgig commented Oct 4, 2022

svd is used by steadystate.

There are no method in common between Dense and CSR, the default is solve for Dense, but spsolve for CSR. All iterative methods are only available in sparse.linalg... So we cannot pass it anywhere thus I think it won't be hard to remember.

If we want to have the default change depending on whether we have mkl or not, we could read the default method from core's settings.

@Ericgig Ericgig mentioned this pull request Oct 12, 2022
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants