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

Clean up and simplify optimization interface #127

Merged
merged 29 commits into from
Feb 11, 2025
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6211f4d
Update PEPSKit.Defaults
pbrehmer Feb 4, 2025
1916e2b
Break up peps_opt.jl into two files
pbrehmer Feb 4, 2025
c4e0436
Add symmetrization to PEPSOptimize
pbrehmer Feb 4, 2025
ab794ba
Fix realness warning in fixedpoint
pbrehmer Feb 4, 2025
42766e3
Rename `costfun` to `cost_function` and add docstring
pbrehmer Feb 5, 2025
9afaf5f
Clean up tests
pbrehmer Feb 5, 2025
dba99e4
Make PEPSKit.fixedpoint argument order consistent with MPSKit.fixedpo…
pbrehmer Feb 5, 2025
80f003d
Add truncation_error and condition_number to CTMRG info return tuples
pbrehmer Feb 5, 2025
6a8e739
Adapt leading_boundary calls to additional info return value
pbrehmer Feb 5, 2025
31e32bd
Adapt leading_boundary rrule to info tuple
pbrehmer Feb 5, 2025
ba17a81
Make changes runnable
pbrehmer Feb 6, 2025
3adbc67
Merge branch 'master' into pb-clean-opt-interface
pbrehmer Feb 6, 2025
3dc602f
Add collection of truncation errors, condition numbers, etc. during o…
pbrehmer Feb 6, 2025
e773be5
Adapt tests and examples to new fixedpoint return values
pbrehmer Feb 6, 2025
a027a3f
Fix tests (1st try)
pbrehmer Feb 6, 2025
799d9e8
Fix tests (2nd try)
pbrehmer Feb 6, 2025
a5c5e2a
Apply suggestions
pbrehmer Feb 7, 2025
3bad3da
Rename `envs` to `env`
pbrehmer Feb 7, 2025
1267077
Backpropagate _condition_number with ZeroTangent
pbrehmer Feb 7, 2025
d4c620b
Update src/algorithms/ctmrg/simultaneous.jl
pbrehmer Feb 7, 2025
8c93c6e
Relocate computation of condition to projectors
pbrehmer Feb 7, 2025
38d42ac
Merge branch 'pb-clean-opt-interface' of github.com:quantumghent/PEPS…
pbrehmer Feb 7, 2025
58b4570
Use `@ignore_derivatives` for _condition_number
pbrehmer Feb 7, 2025
bf09931
Apply local info suggestion
pbrehmer Feb 7, 2025
6afe263
Replace Zygote.Buffers in CTMRG
pbrehmer Feb 10, 2025
534e6f9
Merge branch 'pb-clean-opt-interface' of github.com:quantumghent/PEPS…
pbrehmer Feb 10, 2025
ea46eb2
Fix condition number computation
pbrehmer Feb 10, 2025
7d4f51f
Fix _condition_number
pbrehmer Feb 10, 2025
e7077a3
Compose first and last directly
pbrehmer Feb 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/algorithms/ctmrg/projectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@
end

# TODO: add `LinearAlgebra.cond` to TensorKit
# Compute condition number σ_max / σ_min for diagonal singular value TensorMap
# Compute condition number smax / smin for diagonal singular value TensorMap
function _condition_number(S::AbstractTensorMap)
# Take maximal condition number over all blocks
return maximum(blocks(S)) do (_, b)
b_diag = diag(b)
return maximum(b_diag) / minimum(b_diag)
end
smax = maximum(first, last.(values(blocks(S))))
smin = minimum(last, last.(values(blocks(S))))
return smax / smin

Check warning on line 64 in src/algorithms/ctmrg/projectors.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/ctmrg/projectors.jl#L61-L64

Added lines #L61 - L64 were not covered by tests
end
@non_differentiable _condition_number(S::AbstractTensorMap)

Expand All @@ -77,7 +75,7 @@
# SVD half-infinite environment
halfinf = half_infinite_environment(enlarged_corners...)
svd_alg = svd_algorithm(alg, coordinate)
U, S, V, truncation_error = PEPSKit.tsvd!(halfinf, svd_alg; trunc=alg.trscheme)

Check warning on line 78 in src/algorithms/ctmrg/projectors.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/ctmrg/projectors.jl#L78

Added line #L78 was not covered by tests

# Check for degenerate singular values
Zygote.isderiving() && ignore_derivatives() do
Expand All @@ -88,9 +86,9 @@
end

P_left, P_right = contract_projectors(U, S, V, enlarged_corners...)
truncation_error /= norm(S)
condition_number = @ignore_derivatives(_condition_number(S))
return (P_left, P_right), (; truncation_error, condition_number, U, S, V)

Check warning on line 91 in src/algorithms/ctmrg/projectors.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/ctmrg/projectors.jl#L89-L91

Added lines #L89 - L91 were not covered by tests
end
function compute_projector(enlarged_corners, coordinate, alg::FullInfiniteProjector)
halfinf_left = half_infinite_environment(enlarged_corners[1], enlarged_corners[2])
Expand All @@ -99,7 +97,7 @@
# SVD full-infinite environment
fullinf = full_infinite_environment(halfinf_left, halfinf_right)
svd_alg = svd_algorithm(alg, coordinate)
U, S, V, truncation_error = PEPSKit.tsvd!(fullinf, svd_alg; trunc=alg.trscheme)

Check warning on line 100 in src/algorithms/ctmrg/projectors.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/ctmrg/projectors.jl#L100

Added line #L100 was not covered by tests

# Check for degenerate singular values
Zygote.isderiving() && ignore_derivatives() do
Expand All @@ -110,6 +108,6 @@
end

P_left, P_right = contract_projectors(U, S, V, halfinf_left, halfinf_right)
condition_number = @ignore_derivatives(_condition_number(S))
return (P_left, P_right), (; truncation_error, condition_number, U, S, V)

Check warning on line 112 in src/algorithms/ctmrg/projectors.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/ctmrg/projectors.jl#L111-L112

Added lines #L111 - L112 were not covered by tests
end
Loading