-
Notifications
You must be signed in to change notification settings - Fork 6
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
Generalizing WoodburyPDMat #25
Comments
@oxinabox maybe? Thoughts on this? |
I think we can relax the constraints here, but @willtebbutt is probably a better person to confirm this. |
Yup, that seems fine to me. I agree that the important property is that |
Okay, I'll open a PR. |
Heh, may be a while. This code is a bit foggy in my brain now. Either way, this will be a breaking change, as the decompositions needed when |
No problem. If you get a minute, could you elaborate on why this is likely to need a hand-written constructor rrule? |
I recall Zygote throws an error requesting a rule when it hits custom constructors of arrays. But maybe that's just when there are multiple constructors. |
I think that's just for inner constructors. If you handle it with an outer, it should be fine. |
Ah good to know. @willtebbutt, I noticed |
Good question. I think this is an oversight, rather than something intentional. e.g. we regularly compute log determinants of these matrices, and assume they'll be finite. |
Ah, the main blocker here will be that there's currently no ChainRules rrule for
Ah, I should note that the generalization still requires that |
e.g. we could do this: function LinearAlgebra.logdet(W::WoodburyPDMat)
C_S = cholesky(W.S)
C = if W.D isa Diagonal && isposdef(W.D)
C_D = cholesky(W.D)
B = C_S.U' \ (W.A * C_D.U')
Symmetric(muladd(B', B, I))
else
R = qr(C_S.U' \ W.A).R
Symmetric(muladd(R, W.D * R', I))
end
C_C = cholesky(C)
return logdet(C_S) + logdet(C_C)
end |
Ahhh I see. I'm slightly concerned about what this will do for type stability (if |
This should be type-stable. One could design a pathological case where e.g. |
Sorry, I mean on the reverse-pass, specifically with Zygote. It doesn't handle conditionals well, so it's likely that even though the primal should be stable, and each of the rules for each of the expressions is type stable, the forwards / reverse Zygote passes won't be. |
Ugh, right. Well thankfully, with |
WoodburyPDMat
currently requires thatS
andD
both be positive and diagonal. Technically neither of these needs to be the case. For example, in the L-BFGS algorithm, the approximate inverse Hessian that is constructed begins with a diagonal PDS
and constructsD
to be symmetric but non-PD, but such thatS+ADA'
is guaranteed to be PD.Pathfinder.jl includes a
WoodburyPDMat
implementation that releases these constraints and uses a different set of decompositions to get the necessary overloads, but ideally this implementation would live in a more general package. Would you be interested in this implementation being integrated here?The text was updated successfully, but these errors were encountered: