Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
| function _sylvester_psd(U, d, C, tol) | ||
| Y = U' * C * U | ||
| dd = d .+ transpose(d) | ||
| Δ = maximum(abs, (abs.(dd) .< tol) .* Y; init = zero(real(eltype(Y)))) |
There was a problem hiding this comment.
There is a slight mismatch (by a factor of 2) between abs.(dd) .< tol used here, and
isnull = abs.(d) .< tol
isnull .& transpose(isnull)
used in the next function.
|
|
||
| # Extract and check the cotangents | ||
| ΔW, ΔP = ΔWP | ||
| D, U = eigh_full(P) |
There was a problem hiding this comment.
One could of course ask the question, if we compute the polar via the svd, then we already have D and U, namely they are the S and V from the SVD. So do we just want to pass these along? Or do we even want pullbacks at all? AD through the primal polar calculation using SVD should yield the correct result.
There was a problem hiding this comment.
That's true and I got tunnel vision on the case that needed sylvester because it was really annoying me that we were copying back for that. Maybe we could specialize the AD rule just for non-SVD based polar and see if the AD engine(s) can work out the rest?
After staring at the polar PBs/PFs I convinced myself the input to
sylvesteris always Hermitian, so we can get away without using the Schur decomposition which GPUs don't support yet. This means we can get away with just usingeighwhich we do support. For the forward rules I added some logic similar to what we did for QR/LQ and focus only on the gauge invariant part. This also lets us handle rank-deficient inputs which is nice. I didn't go through super intensively to optimize this yet so there may be low hanging performance fruits.