Skip to content

Commit 7d7b745

Browse files
authored
Flush stdout so outputs are printed to file more often (#54)
1 parent 460ec96 commit 7d7b745

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
version:
15-
- '1.3'
15+
- '1.6'
1616
- '1'
1717
os:
1818
- ubuntu-latest
@@ -24,8 +24,8 @@ jobs:
2424
# MacOS not available on x86
2525
- {os: 'macOS-latest', arch: 'x86'}
2626
# Only test all os on the latest release
27-
- {version: '1.3', os: 'windows-latest'}
28-
- {version: '1.3', os: 'macOS-latest'}
27+
- {version: '1.6', os: 'windows-latest'}
28+
- {version: '1.6', os: 'macOS-latest'}
2929
steps:
3030
- uses: actions/checkout@v2
3131
- uses: julia-actions/setup-julia@latest

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1818
[compat]
1919
Compat = "3"
2020
HDF5 = "0.15, 0.16"
21-
ITensors = "0.2, 0.3"
21+
ITensors = "0.3"
2222
Infinities = "0.1"
2323
IterTools = "1"
2424
KrylovKit = "0.5"
2525
OffsetArrays = "1"
2626
QuadGK = "2"
2727
Requires = "1"
28-
julia = "1"
28+
julia = "1.6"
2929

3030
[extras]
3131
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

src/subspace_expansion.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ function subspace_expansion(
158158
println(
159159
"Current bond dimension at bond $b is $dˡ while desired maximum dimension is $maxdim, skipping bond dimension increase",
160160
)
161+
flush(stdout)
162+
flush(stderr)
161163
return.AL[n1], ψ.AL[n2]), ψ.C[n1], (ψ.AR[n1], ψ.AR[n2])
162164
end
163165
maxdim -=
@@ -174,6 +176,8 @@ function subspace_expansion(
174176
println(
175177
"Impossible to do a subspace expansion, probably due to conservation constraints"
176178
)
179+
flush(stdout)
180+
flush(stderr)
177181
return.AL[n1], ψ.AL[n2]), ψ.C[n1], (ψ.AR[n1], ψ.AR[n2])
178182
end
179183

src/vumps_localham.jl

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,11 @@ function tdvp(
555555
N = nsites(ψ)
556556
(ϵᴸ!) = fill(tol, nsites(ψ))
557557
(ϵᴿ!) = fill(tol, nsites(ψ))
558-
outputlevel > 0 &&
558+
if outputlevel > 0
559559
println("Running VUMPS with multisite_update_alg = $multisite_update_alg")
560+
flush(stdout)
561+
flush(stderr)
562+
end
560563
for iter in 1:maxiter
561564
ψ, (eᴸ, eᴿ) = tdvp_iteration(
562565
solver,
@@ -570,13 +573,19 @@ function tdvp(
570573
)
571574
ϵᵖʳᵉˢ = max(maximum(ϵᴸ!), maximum(ϵᴿ!))
572575
maxdimψ = maxlinkdim(ψ[0:(N + 1)])
573-
outputlevel > 0 && println(
574-
"VUMPS iteration $iter (out of maximum $maxiter). Bond dimension = $maxdimψ, energy = $((eᴸ, eᴿ)), ϵᵖʳᵉˢ = $ϵᵖʳᵉˢ, tol = $tol",
575-
)
576+
if outputlevel > 0
577+
println(
578+
"VUMPS iteration $iter (out of maximum $maxiter). Bond dimension = $maxdimψ, energy = $((eᴸ, eᴿ)), ϵᵖʳᵉˢ = $ϵᵖʳᵉˢ, tol = $tol",
579+
)
580+
flush(stdout)
581+
flush(stderr)
582+
end
576583
if ϵᵖʳᵉˢ < tol
577584
println(
578585
"Precision error $ϵᵖʳᵉˢ reached tolerance $tol, stopping VUMPS after $iter iterations (of a maximum $maxiter).",
579586
)
587+
flush(stdout)
588+
flush(stderr)
580589
break
581590
end
582591
end
@@ -599,16 +608,22 @@ function vumps(
599608
)
600609
@assert isinf(time_step) && time_step < 0
601610
println("Using VUMPS solver with time step $time_step")
611+
flush(stdout)
612+
flush(stderr)
602613
return tdvp(vumps_solver, args...; time_step=time_step, solver_tol=solver_tol, kwargs...)
603614
end
604615

605616
function tdvp(args...; time_step, solver_tol=(x -> x / 100), kwargs...)
606617
solver = if !isinf(time_step)
607618
println("Using TDVP solver with time step $time_step")
619+
flush(stdout)
620+
flush(stderr)
608621
tdvp_solver
609622
elseif time_step < 0
610623
# Call VUMPS instead
611624
println("Using VUMPS solver with time step $time_step")
625+
flush(stdout)
626+
flush(stderr)
612627
vumps_solver
613628
else
614629
error("Time step $time_step not supported.")

src/vumps_mpo.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ function left_environment(H::InfiniteMPOMatrix, ψ::InfiniteCanonicalMPS; tol=1e
146146
Ls[1][n], info = linsolve(A, Ls[1][n], 1, -1; tol=tol)
147147
else
148148
println("Not implemented")
149+
flush(stdout)
150+
flush(stderr)
149151
end
150152
end
151153
end
@@ -300,6 +302,8 @@ function right_environment(H::InfiniteMPOMatrix, ψ::InfiniteCanonicalMPS; tol=1
300302
Rs[1][n], info = linsolve(A, Rs[1][n], 1, -1; tol=tol)
301303
else
302304
println("Not yet implemented")
305+
flush(stdout)
306+
flush(stderr)
303307
end
304308
end
305309
end

0 commit comments

Comments
 (0)