Skip to content

Commit 3a14c12

Browse files
committed
small updates
1 parent 23ae439 commit 3a14c12

File tree

4 files changed

+85
-70
lines changed

4 files changed

+85
-70
lines changed

benchmark/MPSKitBenchmarks/derivatives/AC2_benchmarks.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@ function AC2Spec(mps, mpo; site = length(mps) ÷ 2)
1616
return AC2Spec(physicalspaces, mps_virtualspaces, mpo_virtualspaces, ks)
1717
end
1818

19+
benchname(spec::AC2Spec) = dim(spec.mps_virtualspaces[1]), dim(spec.mpo_virtualspaces[1])
20+
1921
# Benchmarks
2022
# ----------
2123
function MPSKit.MPO_AC2_Hamiltonian(spec::AC2Spec{S}; T::Type = Float64) where {S}
2224
GL = randn(T, spec.mps_virtualspaces[1] spec.mpo_virtualspaces[1]' spec.mps_virtualspaces[1])
2325
GR = randn(T, spec.mps_virtualspaces[3] spec.mpo_virtualspaces[3] spec.mps_virtualspaces[3])
24-
W1 = JordanMPOTensor{T, S}(undef, spec.mpo_virtualspaces[1] spec.physicalspaces[1] spec.physicalspaces[1] spec.mpo_virtualspaces[2])
26+
W1 = MPSKit.JordanMPOTensor{T, S}(undef, spec.mpo_virtualspaces[1] spec.physicalspaces[1] spec.physicalspaces[1] spec.mpo_virtualspaces[2])
2527
for (r, c) in spec.nonzero_keys[1]
2628
r == c == 1 && continue
2729
r == size(W1, 1) && c == size(W1, 4) && continue
2830
W1[r, 1, 1, c] = randn!(W1[r, 1, 1, c])
2931
end
30-
W2 = JordanMPOTensor{T, S}(undef, spec.mpo_virtualspaces[2] spec.physicalspaces[2] spec.physicalspaces[2] spec.mpo_virtualspaces[3])
32+
W2 = MPSKit.JordanMPOTensor{T, S}(undef, spec.mpo_virtualspaces[2] spec.physicalspaces[2] spec.physicalspaces[2] spec.mpo_virtualspaces[3])
3133
for (r, c) in spec.nonzero_keys[2]
3234
r == c == 1 && continue
3335
r == size(W2, 1) && c == size(W2, 4) && continue
@@ -68,10 +70,11 @@ function tomlify(spec::AC2Spec)
6870
end
6971

7072
function untomlify(::Type{AC2Spec}, x)
71-
physicalspaces = Tuple(map(untomlify, x["physicalspaces"]))
72-
mps_virtualspaces = Tuple(map(untomlify, x["mps_virtualspaces"]))
73-
mpo_virtualspaces = Tuple(map(untomlify, x["mpo_virtualspaces"]))
74-
nonzero_keys = Tuple(map(Base.Fix1(map, Base.Fix1(map, Tuple)), x["nonzero_keys"]))
73+
to_space = Base.Fix1(untomlify, VectorSpace)
74+
physicalspaces = Tuple(map(to_space, x["physicalspaces"]))
75+
mps_virtualspaces = Tuple(map(to_space, x["mps_virtualspaces"]))
76+
mpo_virtualspaces = Tuple(map(to_space, x["mpo_virtualspaces"]))
77+
nonzero_keys = Tuple(map(Base.Fix1(map, Tuple), x["nonzero_keys"]))
7578
return AC2Spec(physicalspaces, mps_virtualspaces, mpo_virtualspaces, nonzero_keys)
7679
end
7780

benchmark/MPSKitBenchmarks/derivatives/DerivativesBenchmarks.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import ..BenchUtils: tomlify, untomlify
1313
const SUITE = BenchmarkGroup()
1414

1515
const allparams = Dict(
16-
"heisenberg_NN" => TOML.parsefile(joinpath(@__DIR__, "heisenberg_NN_specs.toml"))
16+
"heisenberg_NN" => TOML.parsefile(joinpath(@__DIR__, "heisenberg_NN.toml"))
1717
)
1818

1919
include("AC2_benchmarks.jl")
@@ -26,12 +26,15 @@ suite_apply = addgroup!(SUITE, "AC2_contraction")
2626
for (model, params) in allparams
2727
g_prep = addgroup!(suite_init, model)
2828
g_contract = addgroup!(suite_apply, model)
29-
specs = untomlify.(AC2Spec, params["specs"])
30-
31-
for spec in specs
32-
name = benchname(spec)
33-
g_prep[name] = preparation_benchmark(spec; T)
34-
g_contract[name] = contraction_benchmark(spec; T)
29+
for (symmetry, specs) in params
30+
g_prep_sym = addgroup!(g_prep, symmetry)
31+
g_contract_sym = addgroup!(g_contract, symmetry)
32+
for spec_dict in specs
33+
spec = untomlify(AC2Spec, spec_dict)
34+
name = benchname(spec)
35+
g_prep_sym[name] = preparation_benchmark(spec; T)
36+
g_contract_sym[name] = contraction_benchmark(spec; T)
37+
end
3538
end
3639
end
3740

0 commit comments

Comments
 (0)