Skip to content

Commit 4f33d65

Browse files
borisdevoslkdvoskshyatt
authored
Number of fixes to support latest versions of TensorKit (#416)
* changes related to old `fusionblockstructure` * Ensure `JordanMPOTensor` auto-converts * Fix compat too * update CI * setup workspaces * update BlockTensorKit * drop sources * fix BlockTensorKit link * random type stability change --------- Co-authored-by: lkdvos <ldevos98@gmail.com> Co-authored-by: Katharine Hyatt <kshyatt@users.noreply.github.com>
1 parent 9e000a4 commit 4f33d65

14 files changed

Lines changed: 86 additions & 98 deletions

File tree

.github/workflows/Tests.yml

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
name: Tests
1+
name: CI
2+
23
on:
34
push:
45
branches:
5-
- 'master'
66
- 'main'
7-
- 'release-'
87
tags: '*'
98
paths-ignore:
109
- 'docs/**'
@@ -14,53 +13,14 @@ on:
1413

1514
concurrency:
1615
group: ${{ github.workflow }}-${{ github.ref }}
17-
# Cancel intermediate builds: only if it is a pull request build.
1816
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
1917

2018
jobs:
21-
setup-matrix:
22-
runs-on: ubuntu-latest
23-
outputs:
24-
matrix: ${{ steps.mk.outputs.matrix }}
25-
steps:
26-
- id: mk
27-
shell: bash
28-
run: |
29-
# Draft PR: only run ubuntu-latest + version=1 (all groups)
30-
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.draft }}" == "true" ]]; then
31-
cat >> "$GITHUB_OUTPUT" <<'EOF'
32-
matrix={"version":["1"],"os":["ubuntu-latest"],"group":["states","operators","algorithms","multifusion","misc"]}
33-
EOF
34-
else
35-
cat >> "$GITHUB_OUTPUT" <<'EOF'
36-
matrix={"version":["lts","1"],"os":["ubuntu-latest","windows-latest","macOS-latest"],"group":["states","operators","algorithms","multifusion","misc"]}
37-
EOF
38-
fi
39-
4019
tests:
4120
name: "Tests"
42-
needs: setup-matrix
43-
strategy:
44-
fail-fast: false
45-
matrix: ${{ fromJSON(needs.setup-matrix.outputs.matrix) }}
46-
47-
runs-on: ${{ matrix.os }}
48-
steps:
49-
- uses: actions/checkout@v6
50-
- uses: julia-actions/setup-julia@v2
51-
with:
52-
version: ${{ matrix.version }}
53-
- uses: julia-actions/cache@v3
54-
- uses: julia-actions/julia-buildpkg@v1
55-
- uses: julia-actions/julia-runtest@v1
56-
timeout-minutes: 120
57-
with:
58-
test_args: '--jobs=1 ${{ matrix.group }}'
59-
- uses: julia-actions/julia-processcoverage@v1
60-
with:
61-
directories: 'src,ext'
62-
- uses: codecov/codecov-action@v6
63-
with:
64-
files: lcov.info
65-
token: "${{ secrets.CODECOV_TOKEN }}"
66-
fail_ci_if_error: true
21+
uses: "QuantumKitHub/QuantumKitHubActions/.github/workflows/TestGroups.yml@main"
22+
with:
23+
fast: "${{ github.event.pull_request.draft == true }}"
24+
timeout-minutes: 120
25+
secrets:
26+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Project.toml

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
2929
[extensions]
3030
MPSKitAdaptExt = "Adapt"
3131

32+
[workspace]
33+
projects = ["test", "docs"]
34+
3235
[compat]
3336
Accessors = "0.1"
3437
Adapt = "4"
35-
Aqua = "0.8.9"
36-
BlockTensorKit = "0.3.8"
37-
CUDA = "5.9"
38-
Combinatorics = "1"
38+
BlockTensorKit = "0.3.11"
3939
Compat = "3.47, 4.10"
4040
DocStringExtensions = "0.9.3"
4141
HalfIntegers = "1.6.0"
@@ -45,34 +45,11 @@ LoggingExtras = "~1.0"
4545
MatrixAlgebraKit = "0.6.5"
4646
OhMyThreads = "0.7, 0.8"
4747
OptimKit = "0.3.1, 0.4"
48-
ParallelTestRunner = "2"
49-
Pkg = "1"
50-
Plots = "1.40"
5148
Printf = "1"
5249
Random = "1"
5350
RecipesBase = "1.1"
54-
TensorKit = "0.16.3"
51+
TensorKit = "0.16.5"
5552
TensorKitManifolds = "0.7"
56-
TensorKitTensors = "0.2"
5753
TensorOperations = "5.5.1"
58-
Test = "1"
59-
TestExtras = "0.3"
6054
VectorInterface = "0.2, 0.3, 0.4, 0.5"
61-
cuTENSOR = "2.3"
6255
julia = "1.10"
63-
64-
[extras]
65-
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
66-
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
67-
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
68-
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
69-
ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc"
70-
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
71-
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
72-
TensorKitTensors = "41b62e7d-e9d1-4e23-942c-79a97adf954b"
73-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
74-
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"
75-
cuTENSOR = "011b41b2-24ef-40a8-b3eb-fa098493e9e1"
76-
77-
[targets]
78-
test = ["Aqua", "Adapt", "CUDA", "cuTENSOR", "Pkg", "Test", "TestExtras", "Plots", "Combinatorics", "ParallelTestRunner", "TensorKitTensors"]

docs/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name = "MPSKitDocs"
2+
13
[deps]
24
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
35
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
@@ -12,5 +14,9 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1214
TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
1315
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
1416

17+
[sources]
18+
MPSKit = {path = ".."}
19+
1520
[compat]
1621
Documenter = "1.0"
22+
DocumenterInterLinks = "1"

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ links = InterLinks(
3030
"TensorKit" => "https://quantumkithub.github.io/TensorKit.jl/stable/",
3131
"TensorOperations" => "https://quantumkithub.github.io/TensorOperations.jl/stable/",
3232
"KrylovKit" => "https://jutho.github.io/KrylovKit.jl/stable/",
33-
"BlockTensorKit" => "https://lkdvos.github.io/BlockTensorKit.jl/dev/",
33+
"BlockTensorKit" => "https://quantumkithub.github.io/BlockTensorKit.jl/dev/",
3434
"MatrixAlgebraKit" => "https://quantumkithub.github.io/MatrixAlgebraKit.jl/stable/",
3535
"MPSKitModels" => "https://quantumkithub.github.io/MPSKitModels.jl/dev/"
3636
)

src/algorithms/expval.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,14 @@ function expectation_value(
132132
ψ::InfiniteMPS, H::InfiniteMPOHamiltonian,
133133
envs::AbstractMPSEnvironments = environments(ψ, H)
134134
)
135-
return sum(1:length(ψ)) do site
136-
return contract_mpo_expval(
135+
T = TensorOperations.promote_contract(scalartype(ψ), scalartype(H))
136+
s = zero(T)
137+
for site in 1:length(ψ)
138+
s += contract_mpo_expval(
137139
ψ.AC[site], envs.GLs[site], H[site][:, 1, 1, end], envs.GRs[site][end]
138-
)
140+
)::T
139141
end
142+
return s
140143
end
141144

142145
# MPO tensor

src/operators/jordanmpotensor.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ struct JordanMPOTensor{
4949
# constructor from data
5050
function JordanMPOTensor{E, S, TA, TB, TC, TD}(
5151
V::TensorMapSumSpace,
52-
A::SparseBlockTensorMap{TA, E, S, 2, 2},
53-
B::SparseBlockTensorMap{TB, E, S, 2, 1},
54-
C::SparseBlockTensorMap{TC, E, S, 1, 2},
55-
D::SparseBlockTensorMap{TD, E, S, 1, 1}
52+
A::SparseBlockTensorMap{<:Any, <:Any, S, 2, 2},
53+
B::SparseBlockTensorMap{<:Any, <:Any, S, 2, 1},
54+
C::SparseBlockTensorMap{<:Any, <:Any, S, 1, 2},
55+
D::SparseBlockTensorMap{<:Any, <:Any, S, 1, 1}
5656
) where {E, S, TA, TB, TC, TD}
5757
return new{E, S, TA, TB, TC, TD}(V, A, B, C, D)
5858
end

src/utility/utility.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,15 @@ function mul_front!(
251251
cp = allocator_checkpoint!(allocator)
252252

253253
Ablocks = blocks(A)
254-
Bstructure = TensorKit.fusionblockstructure(space(B))
254+
Bstructure = TensorKit.subblockstructure(space(B))
255255
for ((f₁, f₂), c) in subblocks(C)
256256
# fetch A block
257257
u = first(f₁.uncoupled)
258258
a = Ablocks[u]
259259
isempty(a) && (scale!(c, β); continue)
260260

261261
# fetch B block
262-
haskey(Bstructure.fusiontreeindices, (f₁, f₂)) || (scale!(c, β); continue)
262+
haskey(Bstructure, (f₁, f₂)) || (scale!(c, β); continue)
263263
b = B[f₁, f₂]
264264

265265
tensorcontract!(
@@ -299,7 +299,7 @@ function mul_tail!(
299299

300300
cp = allocator_checkpoint!(allocator)
301301

302-
Astructure = TensorKit.fusionblockstructure(space(A))
302+
Astructure = TensorKit.subblockstructure(space(A))
303303
Bblocks = blocks(B)
304304
for ((f₁, f₂), c) in subblocks(C)
305305
# fetch B block
@@ -308,7 +308,7 @@ function mul_tail!(
308308
isempty(b) && (scale!(c, β); continue)
309309

310310
# fetch A block
311-
haskey(Astructure.fusiontreeindices, (f₁, f₂)) || (scale!(c, β); continue)
311+
haskey(Astructure, (f₁, f₂)) || (scale!(c, β); continue)
312312
a = A[f₁, f₂]
313313

314314
tensorcontract!(

test/Project.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name = "MPSKitTests"
2+
3+
[deps]
4+
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
5+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
6+
BlockTensorKit = "5f87ffc2-9cf1-4a46-8172-465d160bd8cd"
7+
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
8+
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
9+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
10+
MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4"
11+
MPSKit = "bb1c41ca-d63c-52ed-829e-0820dda26502"
12+
ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc"
13+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
14+
TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
15+
TensorKitTensors = "41b62e7d-e9d1-4e23-942c-79a97adf954b"
16+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
17+
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"
18+
VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"
19+
cuTENSOR = "011b41b2-24ef-40a8-b3eb-fa098493e9e1"
20+
21+
[compat]
22+
Aqua = "0.8.9"
23+
CUDA = "5.9"
24+
Combinatorics = "1"
25+
ParallelTestRunner = "2"
26+
Plots = "1.40"
27+
TensorKitTensors = "0.2"
28+
Test = "1"
29+
TestExtras = "0.3"
30+
cuTENSOR = "2.3"
31+
32+
[sources]
33+
MPSKit = {path = ".."}

0 commit comments

Comments
 (0)