Skip to content

Commit c9ffc28

Browse files
leburgelclaude
andcommitted
Name the svd and eigh pullbacks' solver tolerance stein_rtol
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 8e90e6f commit c9ffc28

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎src/pullbacks/eigh.jl‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ end
122122
ΔA::AbstractMatrix, A, DV, ΔDV;
123123
degeneracy_atol::Real = default_pullback_rank_atol(DV[1]),
124124
gauge_atol::Real = default_pullback_gauge_atol(ΔDV[2]),
125-
cg_rtol::Real = eps(real(eltype(ΔA)))^(3 / 4)
125+
stein_rtol::Real = eps(real(eltype(ΔA)))^(3 / 4)
126126
)
127127
128128
Adds the pullback from the truncated Hermitian eigenvalue decomposition of `A` to `ΔA`,
@@ -141,13 +141,13 @@ of `V' * ΔV` to rows `i` and columns `j` for which `abs(D[i] - D[j]) < degenera
141141
not small compared to `gauge_atol`.
142142
143143
The contribution from outside the kept eigenvectors is solved by conjugate gradients, to an
144-
error of about `cg_rtol` relative to its right-hand side.
144+
error of about `stein_rtol` relative to its right-hand side.
145145
"""
146146
function eigh_trunc_pullback!(
147147
ΔA::AbstractMatrix, A, DV, ΔDV;
148148
degeneracy_atol::Real = default_pullback_rank_atol(DV[1]),
149149
gauge_atol::Real = default_pullback_gauge_atol(ΔDV[2]),
150-
cg_rtol::Real = eps(real(eltype(ΔA)))^(3 / 4),
150+
stein_rtol::Real = eps(real(eltype(ΔA)))^(3 / 4),
151151
maxiter::Int = 10 * size(ΔA, 1) # conjugate-gradient iterations
152152
)
153153

@@ -168,7 +168,7 @@ function eigh_trunc_pullback!(
168168
X₀ = rdiv!(ΔV₊, Diagonal(D))
169169
AP = mul!(copy(A), V * Dmat, V', -1, 1)
170170
X = hermitian_stein_cg!(
171-
X₀, nothing, () -> AP, inv.(D), cg_rtol * norm(X₀), maxiter;
171+
X₀, nothing, () -> AP, inv.(D), stein_rtol * norm(X₀), maxiter;
172172
cost_apply = n^2, cost_form = 0, cost_square = n^3 + n^2 * p
173173
)
174174
Z .+= X

‎src/pullbacks/svd.jl‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ end
202202
rank_atol::Real = default_pullback_rank_atol(USVᴴ[2]),
203203
degeneracy_atol::Real = default_pullback_rank_atol(USVᴴ[2]),
204204
gauge_atol::Real = default_pullback_gauge_atol(ΔUSVᴴ...),
205-
cg_rtol::Real = eps(real(eltype(ΔA)))^(3 / 4)
205+
stein_rtol::Real = eps(real(eltype(ΔA)))^(3 / 4)
206206
)
207207
208208
Adds the pullback from the truncated SVD of `A` to `ΔA`, given the output `USVᴴ` and the
@@ -220,14 +220,14 @@ anti-hermitian part of `U' * ΔU + Vᴴ * ΔVᴴ'`, restricted to rows `i` and c
220220
which `abs(S[i] - S[j]) < degeneracy_atol`, is not small compared to `gauge_atol`.
221221
222222
The contribution from outside the kept singular vectors is solved by conjugate gradients, to
223-
an error of about `cg_rtol` relative to its right-hand side.
223+
an error of about `stein_rtol` relative to its right-hand side.
224224
"""
225225
function svd_trunc_pullback!(
226226
ΔA::AbstractMatrix, A, USVᴴ, ΔUSVᴴ;
227227
rank_atol::Real = 0,
228228
degeneracy_atol::Real = default_pullback_rank_atol(USVᴴ[2]),
229229
gauge_atol::Real = default_pullback_gauge_atol(ΔUSVᴴ...),
230-
cg_rtol::Real = eps(real(eltype(ΔA)))^(3 / 4),
230+
stein_rtol::Real = eps(real(eltype(ΔA)))^(3 / 4),
231231
maxiter::Int = 10 * minimum(size(ΔA)) # conjugate-gradient iterations
232232
)
233233
# Extract the SVD components
@@ -265,7 +265,7 @@ function svd_trunc_pullback!(
265265
APᴴZ = similar(X, n, p) # for applying AP AP' without forming it
266266
X = hermitian_stein_cg!(
267267
X, (GZ, Z) -> mul!(GZ, AP, mul!(view(APᴴZ, :, axes(Z, 2)), AP', Z)), () -> AP * AP',
268-
S⁻¹ .^ 2, cg_rtol * norm(X), maxiter;
268+
S⁻¹ .^ 2, stein_rtol * norm(X), maxiter;
269269
cost_apply = 2 * m * n, cost_apply_formed = m^2, cost_form = m^2 * n
270270
)
271271
Yᴴ = lmul!(Diagonal(S⁻¹), X' * AP)
@@ -278,7 +278,7 @@ function svd_trunc_pullback!(
278278
APZ = similar(Y, m, p) # for applying AP' AP without forming it
279279
Y = hermitian_stein_cg!(
280280
Y, (GZ, Z) -> mul!(GZ, AP', mul!(view(APZ, :, axes(Z, 2)), AP, Z)), () -> AP' * AP,
281-
S⁻¹ .^ 2, cg_rtol * norm(Y), maxiter;
281+
S⁻¹ .^ 2, stein_rtol * norm(Y), maxiter;
282282
cost_apply = 2 * m * n, cost_apply_formed = n^2, cost_form = n^2 * m
283283
)
284284
X = rmul!(AP * Y, Diagonal(S⁻¹))

0 commit comments

Comments
 (0)