You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR threads the backend and allocators through the DMRG implementations.
As a result, we can use a single buffer that captures all temporary intermediate tensors in the effective hamiltonian applications, which is reused across sites, hopefully alleviating quite a bit of pressure from the garbage collector.
The one thing about this that is somewhat unfortunate is that this turns the algorithms into a non-threadsafe construction, and reusing the same algorithm in a parallel parameter sweep would yield wrong results.
In principle I can try to circumvent this, but I'm wondering how much that is worth it in the end?
Side note: The goal is of course to also do this for the rest of the package, but it is slightly easier to focus on a single algorithm first.
End-to-end DMRG2 ground-state run measuring the effect of reusing a BufferAllocator across the sweep, driven by benchmark/allocator_gc.sbatch / benchmark/allocator_gc_run.jl.
Setup: spin-1 Heisenberg chain (Trivial), L=100, χ=128, 5 fixed sweeps, krylovdim=20, non-adaptive eigensolver (identical work for both allocators). Single Julia thread (so GC is single-threaded and its wall time is a clean number), MKL with 16 threads. julia 1.12.6.
metric (steady-state)
DefaultAllocator
BufferAllocator
change
wall time
65.5 s
50.4 s
−23%
GC time
24.2 s (37%)
10.3 s (20.5%)
−57%
allocated
110.85 GiB
39.85 GiB
−64% (−71 GiB)
GC pauses
~311
~137
−56%
full collections
22
9
−59%
ground-state energy
−138.940086126678
−138.940086126678
Δ = 0
Of the ~111 GiB a sweep churns through, ~71 GiB is recyclable effective-operator contraction scratch — with BufferAllocator it now comes from the reused buffer instead of the GC heap. The residual ~40 GiB (Krylov basis vectors, the gauge-step SVD, environment updates, result tensors) is not managed by the operator allocator and is therefore identical for both — that's the floor.
Raw output
model=Heisenberg S=1 L=100 χ=128 sweeps=5 krylovdim=20 reps=3
julia=1.12.6 julia_threads=1 gc_threads=1 BLAS_threads=16
DefaultAllocator | rep 1/3 | 66.79 s | GC 25.48 s ( 38.1%) | 110.85 GiB | 320 pauses | 23 full
DefaultAllocator | rep 2/3 | 65.62 s | GC 24.24 s ( 36.9%) | 110.85 GiB | 310 pauses | 22 full
DefaultAllocator | rep 3/3 | 65.41 s | GC 24.14 s ( 36.9%) | 110.85 GiB | 313 pauses | 22 full
BufferAllocator | rep 1/3 | 50.91 s | GC 10.34 s ( 20.3%) | 39.85 GiB | 135 pauses | 9 full
BufferAllocator | rep 2/3 | 50.37 s | GC 10.33 s ( 20.5%) | 39.85 GiB | 137 pauses | 9 full
BufferAllocator | rep 3/3 | 50.38 s | GC 10.32 s ( 20.5%) | 39.85 GiB | 137 pauses | 9 full
energy check: |Δ| = 0.00e+00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR threads the
backendandallocators through the DMRG implementations.As a result, we can use a single buffer that captures all temporary intermediate tensors in the effective hamiltonian applications, which is reused across sites, hopefully alleviating quite a bit of pressure from the garbage collector.
The one thing about this that is somewhat unfortunate is that this turns the algorithms into a non-threadsafe construction, and reusing the same algorithm in a parallel parameter sweep would yield wrong results.
In principle I can try to circumvent this, but I'm wondering how much that is worth it in the end?
Side note: The goal is of course to also do this for the rest of the package, but it is slightly easier to focus on a single algorithm first.