Skip to content

Commit 946cc63

Browse files
committed
Precomputed derivatives IV
Revert "Precomputed derivatives III" This reverts commit d704ccf. Precomputed derivatives IV Precomputed derivatives V reduce test terminal clutter update plots script playing around with more kernels remove piracy rework jordanmpo small fix
1 parent b5f68cd commit 946cc63

File tree

10 files changed

+581
-129
lines changed

10 files changed

+581
-129
lines changed

benchmark/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ BlockTensorKit = "5f87ffc2-9cf1-4a46-8172-465d160bd8cd"
44
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
55
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
66
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
7+
MKL = "33e6dc65-8f57-5167-99aa-e5a354878fb2"
78
MPSKit = "bb1c41ca-d63c-52ed-829e-0820dda26502"
89
MPSKitModels = "ca635005-6f8c-4cd1-b51d-8491250ef2ab"
910
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
1011
TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
12+
TensorKitManifolds = "11fa318c-39cb-4a83-b1ed-cdc7ba1e3684"

benchmark/plot_results.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ using Statistics
88
resultdir = joinpath(@__DIR__, "results")
99
resultfile(i) = "results_MPSKit@bench$i.json"
1010

11+
versions = [0, 1, 2, 3, 5]
12+
1113
df_contract = let df = DataFrame(
1214
:version => Int[], :model => String[], :symmetry => String[],
1315
:D => Int[], :V => Int[], :memory => Int[], :allocs => Int[], :times => Vector{Int}[]
1416
)
1517

16-
for version in 0:3
18+
for version in versions
1719
result = JSON.parsefile(joinpath(resultdir, resultfile(version)))
1820
for (model, model_res) in result.data.derivatives.data.AC2_contraction.data
1921
for (symmetry, sym_res) in model_res.data
@@ -35,7 +37,7 @@ df_prep = let df = DataFrame(
3537
:D => Int[], :V => Int[], :memory => Int[], :allocs => Int[], :times => Vector{Int}[]
3638
)
3739

38-
for version in 0:3
40+
for version in versions
3941
result = JSON.parsefile(joinpath(resultdir, resultfile(version)))
4042
for (model, model_res) in result.data.derivatives.data.AC2_preparation.data
4143
for (symmetry, sym_res) in model_res.data

src/MPSKit.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ using Compat: @compat
6060
# -------
6161
using TensorKit
6262
using TensorKit: BraidingTensor
63+
using TensorKit: TupleTools as TT
6364
using MatrixAlgebraKit
6465
using MatrixAlgebraKit: TruncationStrategy, PolarViaSVD, LAPACK_SVDAlgorithm
6566
using BlockTensorKit
@@ -141,6 +142,7 @@ include("environments/lazylincocache.jl")
141142
include("algorithms/fixedpoint.jl")
142143
include("algorithms/derivatives/derivatives.jl")
143144
include("algorithms/derivatives/mpo_derivatives.jl")
145+
include("algorithms/derivatives/hamiltonian_derivatives.jl")
144146
include("algorithms/derivatives/projection_derivatives.jl")
145147
include("algorithms/expval.jl")
146148
include("algorithms/toolbox.jl")

src/algorithms/derivatives/derivatives.jl

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -217,27 +217,15 @@ Base.:*(h::LazySum{<:Union{DerivativeOrMultiplied}}, v) = h(v)
217217
# Operator preparation
218218
# --------------------
219219
"""
220-
prepare_operator!!(O, x, [backend], [allocator]) -> O′, x
220+
prepare_operator!!(O, [backend], [allocator]) -> O′
221221
222222
Given an operator and vector, try to construct a more efficient representation of that operator for repeated application.
223223
This should always be used in conjunction with [`unprepare_operator!!`](@ref).
224224
"""
225-
function prepare_operator!!(
226-
O, x,
227-
backend::AbstractBackend = DefaultBackend(), allocator = DefaultAllocator()
228-
)
229-
return O, x
230-
end
231-
232-
"""
233-
unprepare_operator!!(y, O, x, [backend], [allocator]) -> y′
225+
prepare_operator!!(O, backend::AbstractBackend = DefaultBackend(), allocator = DefaultAllocator()) = O
234226

235-
Given the result `y` of applying a prepared operator `O` on vectors like `x`, undo the preparation work on the vector, and clean up the operator.
236-
This should always be used in conjunction with [`prepare_operator!!`](@ref).
237-
"""
238-
function unprepare_operator!!(
239-
y, O, x,
240-
backend::AbstractBackend = DefaultBackend(), allocator = DefaultAllocator()
241-
)
242-
return y
243-
end
227+
# to make benchmark scripts run
228+
prepare_operator!!(O, x::AbstractTensorMap, backend::AbstractBackend = DefaultBackend(), allocator = DefaultAllocator()) =
229+
prepare_operator!!(O, backend, allocator), x
230+
unprepare_operator!!(y, O, x, backend::AbstractBackend = DefaultBackend(), allocator = DefaultAllocator()) =
231+
y

0 commit comments

Comments
 (0)