I modified ITensorsβ inner product code in abstractmps.jl to simply retry a bunch of times if it gets NaN answers, and it works most of the time. This looks like a bug but I have no idea where itβs coming from. The behaviour is also present when using DoubleFloats.jl, so it is likely an issue with ITensors.
Hereβs how I changed abstractmps.jl:
if !isfinite(dot_M1_M2) || isnan(dot_M1_M2)
# Retry a few times
for i in 2:11
O = M1dag[1] * M2[1]
for j in eachindex(M1)[2:end]
O = (O * M1dag[j]) * M2[j]
end
dot_M1_M2 = O[]
if isfinite(dot_M1_M2) && !isnan(dot_M1_M2)
println("Worked on try ", i)
return dot_M1_M2
end
end
error("The inner product (or normΒ²) you are computing is very large " *
"($dot_M1_M2). You should consider using `lognorm` or `loginner` instead, " *
"which will help avoid floating point errors. For example if you are trying " *
"to normalize your MPS/MPO `A`, the normalized MPS/MPO `B` would be given by " *
"`B = A ./ z` where `z = exp(lognorm(A) / length(A))`.")
end
A minimal example file drawing on @kmp5 's example:
# using Octavian
using GenericLinearAlgebra, MultiFloats, ITensors, DoubleFloats
MultiFloats.use_clean_multifloat_arithmetic()
N = 10
sites = siteinds("S=1", N)
# T = Double64
# T = Float64x1
T = Float64x2
Οβ = randomMPS(T,sites)
println(Οβ.data)
for i in 1:100
print("$i\t")
try
@show inner(Οβ,Οβ)
catch
@show loginner(Οβ,Οβ)
end
end
gives the output
ITensor[ITensor ord=2
Dim 1: (dim=3|id=955|"S=1,Site,n=1")
Dim 2: (dim=1|id=475|"Link,l=1")
NDTensors.Dense{MultiFloat{Float64, 2}, Vector{MultiFloat{Float64, 2}}}
3Γ1
0.9024682454819287533157501021796001
-0.3696171004913222062250941721199386
-0.2212109059724610504166110400916367, ITensor ord=3
Dim 1: (dim=1|id=475|"Link,l=1")
Dim 2: (dim=3|id=655|"S=1,Site,n=2")
Dim 3: (dim=1|id=445|"Link,l=2")
NDTensors.Dense{MultiFloat{Float64, 2}, Vector{MultiFloat{Float64, 2}}}
1Γ3Γ1
[:, :, 1] =
-0.1214899423332925510789074311245403 0.8073751098711058074946163233476233 -0.5773955540809723590037545389624751, ITensor ord=3
Dim 1: (dim=1|id=445|"Link,l=2")
Dim 2: (dim=3|id=498|"S=1,Site,n=3")
Dim 3: (dim=1|id=927|"Link,l=3")
NDTensors.Dense{MultiFloat{Float64, 2}, Vector{MultiFloat{Float64, 2}}}
1Γ3Γ1
[:, :, 1] =
-0.5064928114790571647843660904146737 0.8431578131772069103199533635408137 0.1804160026113828622999509294773879, ITensor ord=3
Dim 1: (dim=1|id=927|"Link,l=3")
Dim 2: (dim=3|id=293|"S=1,Site,n=4")
Dim 3: (dim=1|id=174|"Link,l=4")
NDTensors.Dense{MultiFloat{Float64, 2}, Vector{MultiFloat{Float64, 2}}}
1Γ3Γ1
[:, :, 1] =
-0.3191126839212917625819365200272996 -0.946777071476780535655682514790659 -0.04219326825929627416190420498243662, ITensor ord=3
Dim 1: (dim=1|id=174|"Link,l=4")
Dim 2: (dim=3|id=993|"S=1,Site,n=5")
Dim 3: (dim=1|id=18|"Link,l=5")
NDTensors.Dense{MultiFloat{Float64, 2}, Vector{MultiFloat{Float64, 2}}}
1Γ3Γ1
[:, :, 1] =
-0.8031895842734982090707786359839693 0.1815289084819520257431632178941978 -0.5673920576637605739629228029228936, ITensor ord=3
Dim 1: (dim=1|id=18|"Link,l=5")
Dim 2: (dim=3|id=223|"S=1,Site,n=6")
Dim 3: (dim=1|id=601|"Link,l=6")
NDTensors.Dense{MultiFloat{Float64, 2}, Vector{MultiFloat{Float64, 2}}}
1Γ3Γ1
[:, :, 1] =
-0.86778737294072372026144189447951304 -0.4929202929815074806905301272856098 0.06304490567573332661272029639758355, ITensor ord=3
Dim 1: (dim=1|id=601|"Link,l=6")
Dim 2: (dim=3|id=92|"S=1,Site,n=7")
Dim 3: (dim=1|id=641|"Link,l=7")
NDTensors.Dense{MultiFloat{Float64, 2}, Vector{MultiFloat{Float64, 2}}}
1Γ3Γ1
[:, :, 1] =
-0.9177125536684423210132744144358787 -0.25395896544991142559992191895038103 -0.3054644213438891928395291360024312, ITensor ord=3
Dim 1: (dim=1|id=641|"Link,l=7")
Dim 2: (dim=3|id=134|"S=1,Site,n=8")
Dim 3: (dim=1|id=809|"Link,l=8")
NDTensors.Dense{MultiFloat{Float64, 2}, Vector{MultiFloat{Float64, 2}}}
1Γ3Γ1
[:, :, 1] =
0.50909567473115157572078113943343113 -0.6482621284662864778043189450994564 0.5661959084684323308770663982549032, ITensor ord=3
Dim 1: (dim=1|id=809|"Link,l=8")
Dim 2: (dim=3|id=944|"S=1,Site,n=9")
Dim 3: (dim=1|id=277|"Link,l=9")
NDTensors.Dense{MultiFloat{Float64, 2}, Vector{MultiFloat{Float64, 2}}}
1Γ3Γ1
[:, :, 1] =
0.6085265473196872972354489811738419 -0.672543287340768222824019589446403 -0.4211661998072177280194636967728686, ITensor ord=2
Dim 1: (dim=1|id=277|"Link,l=9")
Dim 2: (dim=3|id=16|"S=1,Site,n=10")
NDTensors.Dense{MultiFloat{Float64, 2}, Vector{MultiFloat{Float64, 2}}}
1Γ3
-0.6876961251864609565734127202335213 0.4556496089484765675765650908914224 0.5652056911148611240955093601848548]
1 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
2 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
3 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
4 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
5 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
6 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
7 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
8 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
9 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
10 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
11 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
12 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
13 Worked on try 3
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
14 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
15 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
16 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
17 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
18 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
19 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
20 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
21 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
22 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
23 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
24 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
25 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
26 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
27 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
28 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
29 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
30 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
31 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
32 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
33 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
34 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
35 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
36 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
37 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
38 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
39 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
40 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
41 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
42 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
43 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
44 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
45 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
46 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
47 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
48 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
49 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
50 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
51 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
52 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
53 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
54 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
55 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
56 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
57 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
58 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
59 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
60 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
61 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
62 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
63 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
64 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
65 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
66 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
67 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
68 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
69 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
70 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
71 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
72 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
73 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
74 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
75 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
76 Worked on try 3
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
77 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
78 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
79 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
80 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
81 Worked on try 2
inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
82 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
83 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
84 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
85 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
86 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
87 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
88 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
89 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
90 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
91 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
92 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
93 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
94 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
95 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
96 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
97 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
98 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
99 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358
100 inner(Οβ, Οβ) = 0.9999999999999999999999999999999815110725338825358