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

Wrappers forscipy.linalgquadratic control solvers (lyapunov, ARE) #19109

Open
jessegrabowski opened this issue Dec 23, 2023 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@jessegrabowski
Copy link

Please:

  • [x ] Check for duplicate requests.
  • [x ] Describe your goal, and if possible provide a code snippet with a motivating example.

I'm interested in implementing solve_discrete_lyapunov, solve_continuous_lyapunov, and solve_discrete_are from scipy.linalg as JAX primitives. My particular use-case is Kalman filtering -- these functions are handy for computing initial and steady-state covariance matrices, but they also have wide application in linear-quadratic control applications. There are gradients computed in this paper, https://arxiv.org/pdf/2011.11430.pdf and I've also done implementations in PyTensor here and here. I'm relying heavily on compiling pytensor graphs to JAX for high-performance scans, and not having these functions is a bit of a pain-point for me at the moment.

I didn't see these functions from a quick search of the codebase, but I just wanted to check that 1) a contribute would be welcome, and 2) they didn't exist elsewhere in the JAX ecosystem before starting a PR.

@jessegrabowski jessegrabowski added the enhancement New feature or request label Dec 23, 2023
@jessegrabowski jessegrabowski changed the title Wrappers forscipy.linalgsolvers Wrappers forscipy.linalgquadratic control solvers (lyapunov, ARE) Dec 23, 2023
@shoyer
Copy link
Collaborator

shoyer commented Jan 8, 2024

How do you think these solvers match up according to our rubric for JAX scipy wrappers?
https://jax.readthedocs.io/en/latest/jep/18137-numpy-scipy-scope.html

@jessegrabowski
Copy link
Author

jessegrabowski commented Jan 8, 2024

I think they're on the margin. They fail axis 1 spectacularly, but arguably pass the other axes, with varying levels of difficultly in making those arguments. I think they pass on 2, 3, 5, and arguably on 6 -- github code search finds 500-1000 snippets using each of solve_discrete_lyapunov and solve_discrete_are, so it's clearly not as popular as linalg.solve, but more widely used than bessel_jn. I guess the weakest case is on 4, ideally I'd hope to just wrap up some calls to LAPACK for forward computation together with some gradients, but this is likely to be more complicated than I realize (hardware targeting issues? introduction of additional package requirements? I have no idea if either of these would be issues, but I can imagine that they could be).

On the other hand, quadratic control generally and Kalman filtering specifically aren't exactly niche topics in scientific computing, so I'm sure these functions would see some use if they were available. Plus scipy.linalg is in scope. But I could see them belonging in something more like jax-opt, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants