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

Make the rrule for 3-arg dot lazy #788

Open
mohamed82008 opened this issue Mar 23, 2024 · 6 comments
Open

Make the rrule for 3-arg dot lazy #788

mohamed82008 opened this issue Mar 23, 2024 · 6 comments
Assignees

Comments

@mohamed82008
Copy link
Member

Currently this line

dA = @thunk project_A(ΔΩ .* x .* adjoint(y))
leads to a loss of structure because it constructs a dense matrix from 2 vectors. We should make this a lazy outer product (like in SciML/LinearSolve.jl#484) such that the m x n matrix's co-tangent only requires O(m + n) memory. See https://discourse.julialang.org/t/zygote-jl-how-to-get-the-gradient-of-sparse-matrix/59067/12 for the potential gain and suggested implementation. If the idea gets a green light, I will open a PR.

@oxinabox
Copy link
Member

oxinabox commented Apr 4, 2024

I guess the key question is are we willing to add LazyArrays as a dependency?

@oxinabox
Copy link
Member

Since this seems to have come up twice in two different contexts i think we can say that this is worth it and we should add LazyArrays as a dependency.
@mohamed82008 are you able to make the PR?

@mohamed82008
Copy link
Member Author

I am able to yes. I will do it in the weekend unless someone wants to beat me to it. It's basically exactly this implementation https://discourse.julialang.org/t/zygote-jl-how-to-get-the-gradient-of-sparse-matrix/59067/12 plus unit tests.

@albertomercurio
Copy link

Hello, are there any news about this? I would like to implement reverse diff to dot(x, A, x) function with A sparse, but at the moment it converts the A matrix into a dense one.

@mohamed82008
Copy link
Member Author

#796

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

No branches or pull requests

4 participants