Skip to content

Commit

Permalink
Merge pull request #18 from tensor4all/terasaki/drop-support-old-iten…
Browse files Browse the repository at this point in the history
…sors

Use ITensors v0.7 (Drop support for old ITensors <= v0.6)
  • Loading branch information
terasakisatoshi authored Nov 15, 2024
2 parents 7ae37c9 + 6e4dd6f commit 98c4ebf
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "0.3.9"
[deps]
EllipsisNotation = "da5c29d0-fa7d-589e-88eb-ea29b0a81949"
FastMPOContractions = "f6e391d2-8ffa-4d7a-98cd-7e70024481ca"
ITensorMPS = "0d1a4710-d33b-49a5-8f18-73bdf49b47e2"
ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
SparseIR = "4fe2279e-80f0-4adb-8463-ee114ff56b7d"
Expand All @@ -14,7 +15,8 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
[compat]
EllipsisNotation = "1"
FastMPOContractions = "^0.2.2"
ITensors = "^0.3.42, 0.4, 0.5, 0.6"
ITensorMPS = "0.3.1"
ITensors = "0.7"
SparseIR = "^0.96, 0.97, 1"
StaticArrays = "1"
julia = "1"
Expand Down
9 changes: 5 additions & 4 deletions notebook/matvec.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"source": [
"using Revise\n",
"using ITensors\n",
"using ITensorMPS: MPS, randomMPS\n",
"#using ITensorTDVP\n",
"import Quantics"
]
Expand Down Expand Up @@ -79,7 +80,7 @@
"outputs": [],
"source": [
"# Remove the dummy index z\n",
"AB = MPS([AB_ext[2n-1] * AB_ext[2n] * onehot(sitesz[n]=>1) for n in 1:R])"
"AB = MPS([AB_ext[2n-1] * AB_ext[2n] * onehot(sitesz[n] => 1) for n in 1:R])"
]
},
{
Expand All @@ -99,15 +100,15 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.8.5",
"display_name": "Julia 1.11.1",
"language": "julia",
"name": "julia-1.8"
"name": "julia-1.11"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.8.5"
"version": "1.11.1"
},
"orig_nbformat": 4
},
Expand Down
8 changes: 5 additions & 3 deletions notebook/mul.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"source": [
"using Revise\n",
"using ITensors\n",
"using ITensors.SiteTypes: siteinds\n",
"using ITensorMPS: randomMPS\n",
"using Quantics"
]
},
Expand Down Expand Up @@ -79,15 +81,15 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.8.5",
"display_name": "Julia 1.11.1",
"language": "julia",
"name": "julia-1.8"
"name": "julia-1.11"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.8.5"
"version": "1.11.1"
},
"orig_nbformat": 4
},
Expand Down
5 changes: 4 additions & 1 deletion src/Quantics.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#__precompile__(false)
#__precompile__(false)

module Quantics

Expand All @@ -10,7 +10,10 @@ module Quantics

using ITensors
import ITensors
using ITensors.SiteTypes: siteinds
import ITensors.NDTensors: Tensor, BlockSparseTensor, blockview
using ITensorMPS: MPS, MPO, AbstractMPS
using ITensorMPS: findsite, linkinds, linkind

import SparseIR: Fermionic, Bosonic, Statistics
import LinearAlgebra: I
Expand Down
2 changes: 1 addition & 1 deletion src/transformer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function _phase_rotation_mpo(sites::AbstractVector{Index{T}}, θ::Float64)::MPO
R = length(sites)
tensors = [ITensor(true) for _ in 1:R]
for n in 1:R
tensors[n] = op("Phase", sites[n]; ϕ=θ * 2^(R - n))
tensors[n] = ITensors.SiteTypes.op("Phase", sites[n]; ϕ=θ * 2^(R - n))
end
links = [Index(1, "Link,l=$l") for l in 1:(R - 1)]
tensors[1] = ITensor(
Expand Down
3 changes: 2 additions & 1 deletion test/test_with_aqua.jl → test/aqua_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@testitem begin
@testitem "code quality test" begin
using Test
using Aqua
import Quantics

Expand Down
4 changes: 4 additions & 0 deletions test/binaryop_tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@testitem "binaryop_tests.jl/_binaryop" begin
using Test
using ITensors
using ITensorMPS: randomMPS
ITensors.disable_warn_order()
using Quantics
import Random
Expand Down Expand Up @@ -64,6 +65,7 @@ end
@testitem "binaryop_tests.jl/affinetransform" begin
using Test
using ITensors
using ITensorMPS: randomMPS
ITensors.disable_warn_order()
using Quantics
import Random
Expand Down Expand Up @@ -126,6 +128,7 @@ end
@testitem "binaryop_tests.jl/affinetransform_three_vars" begin
using Test
using ITensors
using ITensorMPS: randomMPS
ITensors.disable_warn_order()
using Quantics
import Random
Expand Down Expand Up @@ -248,6 +251,7 @@ end
@testitem "binaryop_tests.jl/shiftop" begin
using Test
using ITensors
using ITensorMPS: randomMPS
ITensors.disable_warn_order()
using Quantics
import Random
Expand Down
4 changes: 3 additions & 1 deletion test/fouriertransform_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
using Test
using Quantics
using ITensors

using ITensorMPS: randomMPS, MPO
using ITensors.SiteTypes: siteinds
# A brute-force implementation of _qft (only for tests)
function _qft_ref(sites; cutoff::Float64=1e-14, sign::Int=1)
abs(sign) == 1 || error("sign must either 1 or -1")
Expand Down Expand Up @@ -41,6 +42,7 @@ end
using Test
using Quantics
using ITensors
using ITensorMPS: randomMPS

function _ft_1d_ref(X, sign, originx, origink)
N = length(X)
Expand Down
3 changes: 2 additions & 1 deletion test/imaginarytime_tests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@testitem "imaginarytime_tests.jl/imaginarytime" begin
using Test
using Quantics
import ITensors: siteinds, Index
using ITensors: siteinds, Index
using ITensors.SiteTypes: op
import ITensors
import SparseIR: Fermionic, Bosonic, FermionicFreq, valueim

Expand Down
2 changes: 2 additions & 0 deletions test/mps_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Test
import Quantics
using ITensors
using ITensors.SiteTypes: siteinds
@testset "onemps" begin
nbit = 3
sites = siteinds("Qubit", nbit)
Expand All @@ -14,6 +15,7 @@ end
using Test
import Quantics
using ITensors
using ITensors.SiteTypes: siteinds
@testset "expqtt" begin
R = 10
sites = siteinds("Qubit", 10)
Expand Down
4 changes: 4 additions & 0 deletions test/mul_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Test
import Quantics
using ITensors
using ITensorMPS: randomMPS, MPO

@testset "_preprocess_matmul" begin
N = 2
Expand Down Expand Up @@ -53,6 +54,7 @@ end
using Test
import Quantics
using ITensors
using ITensorMPS: randomMPS

@testset "matmul" for T in [Float64, ComplexF64]
N = 3
Expand Down Expand Up @@ -120,6 +122,8 @@ end
using Test
import Quantics
using ITensors
using ITensors.SiteTypes: siteinds
using ITensorMPS: randomMPS

"""
Reconstruct 3D matrix
Expand Down
5 changes: 5 additions & 0 deletions test/transformer_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using Test
import Quantics
using ITensors
using ITensors.SiteTypes: siteinds
using ITensorMPS: randomMPS
using LinearAlgebra

@testset "upper_lower_triangle" for upper_or_lower in [:upper, :lower]
Expand Down Expand Up @@ -59,6 +61,7 @@ end
using Test
import Quantics
using ITensors
using ITensorMPS: randomMPS
using LinearAlgebra

@testset "reverseaxis" for bc in [1], nbit in 2:2, rev_carrydirec in [true, false]
Expand Down Expand Up @@ -192,6 +195,7 @@ end
using Test
import Quantics
using ITensors
using ITensorMPS: randomMPS
using LinearAlgebra

@testset "phase_rotation" begin
Expand All @@ -215,6 +219,7 @@ end
using Test
import Quantics
using ITensors
using ITensorMPS: randomMPS
using LinearAlgebra

@testset "shiftaxis" for R in [3], bc in [1, -1], rev_carrydirec in [true, false]
Expand Down
2 changes: 2 additions & 0 deletions test/util_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Test
import Quantics
using ITensors
using ITensors.SiteTypes: siteinds
using ITensorMPS: randomMPS, randomMPO, random_mps, MPO

@testset "_replace_mpo_siteinds!" begin
nbit = 3
Expand Down

0 comments on commit 98c4ebf

Please sign in to comment.