GPU
GPU-accelerated mirrors of the CPU solvers, powered by CUDA.jl. Most entry points accept a type (alias dtype) keyword (ComplexF32, ComplexF64, Float32, Float64). Real types are valid only for real Hamiltonians and real-space outputs; get_bands_gpu (quantics Fourier transform), the non-Hermitian and time-evolution entry points, and chern_marker_gpu require a complex type.
TensorBinding._to_gpu — Method
_to_gpu(x, T) -> x on the GPUUpload a CPU ITensor, MPO or MPS with element type T (each tensor copied densely; an MPO/MPS comes back with fresh orthogonality limits). The only CPU → GPU transfer of the package, and the to_device hook the GPU wrappers pass to the kernels they share with the CPU (whose CPU default _on_host(x, T) returns x).
TensorBinding.density_profile_from_dm_gpu — Function
density_profile_from_dm_gpu(density_mpo, sites=nothing; mode=:direct,
maxdim=100, cutoff=1e-8) -> MPSGPU-resident analogue of density_profile_from_dm. If density_mpo is a CPU MPO it is uploaded once (as ComplexF32); if it is already on GPU it is used in place. The returned profile is a GPU MPS. mode=:complement returns 1 - diag(D) on GPU, summed with maxdim/cutoff on the sites sites (default: the site indices of the diagonal).
TensorBinding.extract_diagonal_to_mps_gpu — Method
extract_diagonal_to_mps_gpu(M::MPO) -> MPSGPU-resident analogue of extract_diagonal_to_mps. M is expected to already be a GPU MPO. The returned MPS stays on GPU, with one-hot tensors matched to the input tensor element type.
TensorBinding.KPM_Tn_gpu — Method
KPM_Tn_gpu(H_mpo, N, sites; scale=nothing, center=0.0, maxdim=40,
dmrg_nsweeps=5, dmrg_maxdim=[10, 20, 40], dmrg_linkdim=4,
cutoff=1e-8, keep_indices=nothing, type=ComplexF32, dtype=nothing,
verbose=true)
-> (Tn_list, scale, center)GPU version of KPM_Tn. Moves the identity and scaled Hamiltonian MPOs to GPU before the recurrence so all Tn tensors stay on GPU; Tn_list holds T0 … TN. Requires using CUDA.
type (alias dtype) is the GPU element type: ComplexF32 (default), ComplexF64, or Float32/Float64 for a real H_mpo. With scale=nothing, scale and center are estimated by DMRG (dmrg_nsweeps, dmrg_maxdim, dmrg_linkdim) and the estimated center replaces the one passed.
If keep_indices is provided (a Set{Int}, 1-based into the returned vector where index 1 = T0, 2 = T1, …), only those Tns are retained in memory. All other slots are set to nothing. The recurrence itself always runs to completion — keep_indices only controls which results are stored.
TensorBinding.get_dos_stochastic_gpu — Method
get_dos_stochastic_gpu(H, Ncheb, ω_phys_vals;
N_sample=50, N_bound=0, seed=42, normalize=false,
dos_weighting=:trace, kernel=:jackson, lambda=4.0,
eta=0.0, m_order=4, maxdim=100, cutoff=1e-8,
verbose=false, printinfo=false, continuum_only=false,
nambu_proj=false, proj_nambu=nothing,
spin_proj=false, proj_s=nothing,
layer_proj=false, proj_layer=nothing,
sublat_proj=false, proj_sl=nothing,
type=ComplexF32, dtype=nothing)
-> Vector{Float64} length NωGPU-accelerated stochastic density of states via MPS Chebyshev KPM.
For each random sample the scaled Hamiltonian MPO lives on GPU and the product- state MPS is transferred to GPU once before the recursion starts. The Chebyshev moments ⟨ψ₀|T_n(H̃)|ψ₀⟩ are scalars pulled to CPU at each step.
The keywords shared with get_dos_stochastic (CPU) mean the same; continuum_only, printinfo and type/dtype are GPU-only, and only binary position spaces are supported. type (alias dtype) is the GPU tensor type: ComplexF32 (default), ComplexF64, or Float32/Float64 for a real H. N_bound (exciton bound-sector enrichment) is supported. Use dos_weighting=:sample to return the unweighted sampled signal avg_full + avg_bound, which is useful when visualising exciton peaks that are otherwise hidden by continuum phase-space factors in the trace DOS. For exciton Hamiltonians, continuum_only=true samples ordered electron-hole product states with x_e != x_h for the N_sample branch.
kernel=:hodc selects the Higher-Order Delta Chebyshev reconstruction (eta, m_order control the contour); its weights already carry the full KPM normalisation, so no √(1−ω²) denominator is applied. eta=0 falls back to 1/(Ncheb+1). Otherwise kernel is a convolution kernel (:jackson default, :lorentz with lambda, :fejer, :dirichlet).
Normalisation: the package's KPM convention (see get_ldos_from_mun): with the convolution kernels the result is the spectral density per unit rescaled energy (ω − H.center)/H.scale times 1/π, so each state integrates to 1/π; multiply by π/H.scale for physical units. kernel=:hodc is normalised to 1 (multiply by 1/H.scale).
TensorBinding.get_ldos_spatial_gpu — Method
get_ldos_spatial_gpu(H, Ncheb, ω_phys_vals;
x_groups=nothing, num_x=H.N, num_y=nothing, num_avg=1,
x_start=1, x_end=H.N, grid=false, xwin=nothing, ywin=nothing,
box_half=0, reduce=:point, sublattice=:auto,
kernel=:jackson, lambda=4.0, maxdim=100, cutoff=1e-8,
verbose=false, printinfo=false,
nambu_proj=false, proj_nambu=nothing,
spin_proj=false, proj_s=nothing,
layer_proj=false, proj_layer=nothing,
sublat_proj=false, proj_sl=nothing,
type=ComplexF32, dtype=nothing)
-> Matrix{Float64} shape (Nω × n_spatial_cols)GPU-accelerated version of get_ldos_spatial (MPO mode only).
Sampling procedures (reduce) — see spatial_sampling_plan.
:point(default) — read the LDOS atnum_x[×num_y]cells /x_groups(optionally box-averaged). Coarse grids alias thin features.:block— integrate overnum_x × num_yblocks (powers of two) by tracing out the within-block bits; gap-free, so thin in-gap edge channels on a large system cannot be missed. The scalable tool for large-scale edge-state maps.
Column layout
- No sublattice DOF:
(Nω × ng), one column per pixel (group or block). - Sublattice resolved:
(Nω × ng×n_sub), interleaved[A₀, B₀, A₁, B₁, …]. - Sublattice averaged (large scale /
:block):(Nω × ng), one value per pixel.
For :block, columns are row-major over coarse pixels (col = ixp + iyp·num_x + 1).
GPU/CPU split
GPU: entire Chebyshev MPO recurrence, aux projections, diagonal extraction, real-space scalar sampling (point eval or block integration). CPU: KPM weight matrix, output accumulation (scalars only).
The keywords shared with get_ldos_spatial mean the same. There is no mode (only the single-pass MPO mode is implemented here; the MPS path is get_ldos_spatial_mps_gpu) and no ordering/conumber_* keywords (binary position spaces only); printinfo prints progress like verbose. type (alias dtype) is the GPU tensor datatype used consistently throughout the MPO recurrence, projections, and diagonal extraction: ComplexF32 (default), ComplexF64, or Float32/Float64 for a real H. A warning is emitted for a 32-bit type with cutoff < 1e-6.
Usage
using CUDA
# point map
ldos = TensorBinding.get_ldos_spatial_gpu(H, 200, ωlist;
x_groups = [[uc] for uc in 1:H.N], maxdim=200, printinfo=true)
# block-integrated large-scale edge-state map (num_x, num_y powers of two)
ldos = TensorBinding.get_ldos_spatial_gpu(H, 200, ωlist;
reduce=:block, num_x=128, num_y=128, sublattice=:average, maxdim=200)Normalisation: the package's KPM convention (see get_ldos_from_mun): the result is the spectral density per unit rescaled energy (ω − H.center)/H.scale times 1/π, so each state integrates to 1/π; multiply by π/H.scale for physical units.
TensorBinding.get_ldos_spatial_mps_gpu — Method
get_ldos_spatial_mps_gpu(H, Ncheb, ω_phys_vals;
x_groups=nothing,
num_x=min(H.N, 100), num_avg=1,
x_start=1, x_end=H.N,
kernel=:jackson, lambda=4.0, eta=0.0, m_order=4,
maxdim=100, cutoff=1e-8,
type=ComplexF32, dtype=nothing,
verbose=false, printinfo=false,
return_maxlinkdim=false,
return_moments=false,
# accepted only to reject a non-default value:
num_y=nothing, grid=false, xwin=nothing, ywin=nothing,
box_half=0, reduce=:point, ordering=:physical,
sublattice=:auto,
nambu_proj=false, proj_nambu=nothing,
spin_proj=false, proj_s=nothing,
layer_proj=false, proj_layer=nothing,
sublat_proj=false, proj_sl=nothing)
-> Matrix{Float64}, or a NamedTuple with return_moments/return_maxlinkdimGPU spatial LDOS from one independent MPS Chebyshev recursion per physical-site probe. Unlike get_ldos_spatial_gpu, this path does not construct an MPO Chebyshev series and supports projected position spaces such as FibonacciPositionSpace.
The rescaled operator is H̃ = (H - H.center * P) / H.scale, where P = physical_projector(H). Probe x is constructed with physical_site_state(H, x), so x is always a 1-based physical site rather than an ambient tensor-register index.
x_groups can be a vector of positions (one output column per position) or a vector of position vectors. In the latter case, all probe LDOS values in a group are averaged into one output column. Without explicit groups, num_x intervals over x_start:x_end are sampled with num_avg approximately equidistant probes per interval. Automatic planning allocates only O(num_x * num_avg) probe indices, so callers can sample a huge projected space without enumerating it by choosing a modest num_x (or by supplying x_groups). The default is at most 100 output columns. The groups come from interval_sampling_plan.
kernel=:hodc uses HODC reconstruction (eta, m_order; eta=0 uses 1/(Ncheb+1)). Other supported kernels are :jackson, :lorentz (lambda), :fejer, and :dirichlet.
type (alias dtype) is the GPU tensor type: ComplexF32 (default), ComplexF64, or Float32/Float64 for a real H. With return_moments=true, the group-averaged raw Chebyshev moments are also returned as a Matrix{Float64} of size (Ncheb, length(x_groups)) (or (Ncheb, num_x) for automatic groups):
moments[n, j] = mean(x -> real(<x|T_(n-1)(Htilde)|x>), group[j]),
where Htilde = (H - H.center * P) / H.scale. These moments contain no kernel weights or energy-dependent normalization, and can therefore be reconstructed later on a different energy grid or with a different KPM kernel.
With return_maxlinkdim=true, maxlinkdims[j] is the largest MPS bond dimension reached by any probe in group j. The extras come back as named fields:
- neither keyword:
ldos return_maxlinkdim=true:(; ldos, maxlinkdims)return_moments=true:(; ldos, moments)- both keywords:
(; ldos, moments, maxlinkdims)
Up to v0.1.1 these were the tuples (ldos, linkdims), (ldos, moments) and (ldos, moments, linkdims), so the second element changed meaning with the keywords; the named fields keep that order, and ldos, links = … still destructures them.
This entry point intentionally supports position-only, one-dimensional point or explicit-group sampling. Grid/window/box/block sampling, non-physical ordering, and auxiliary degrees of freedom (on H or requested through the projection keywords) are rejected with targeted errors. For those features use the MPO GPU path or the CPU get_ldos_spatial implementation.
Normalisation: the package's KPM convention (see get_ldos_from_mun): with the convolution kernels the result is the spectral density per unit rescaled energy (ω − H.center)/H.scale times 1/π, so each state integrates to 1/π; multiply by π/H.scale for physical units. kernel=:hodc is normalised to 1 (multiply by 1/H.scale).
TensorBinding.get_bands_gpu — Method
get_bands_gpu(H, Ncheb, ω_phys_vals;
kpath=nothing, kpath_lattice=nothing, kpath_Lx=nothing,
spin_proj=false, proj_s=nothing, nambu_proj=false, proj_nambu=nothing,
layer_proj=false, proj_layer=nothing, sublattice=false, proj_sl=nothing,
sublat_proj=false, k_groups_override=nothing,
xmin=0, xmax=nothing, num_x=60, num_avg=1,
ymin=0, ymax=nothing, num_y=10,
kernel=:jackson, lambda=4.0, tol=1e-9, maxdim=100, cutoff=1e-10,
printinfo=false, type=ComplexF32, dtype=nothing)
-> Matrix{Float64} or NamedTuple(Ak, ticks, labels)GPU-accelerated version of get_bands.
GPU handles: the full Chebyshev MPO recurrence (the dominant cost) and the QFT sandwich applied to each Chebyshev moment. CPU handles: k-group setup, KPM weight matrix, final scalar accumulation.
Use type=ComplexF32 (default) or type=ComplexF64 to choose the GPU tensor datatype. Real types are rejected, because the quantics Fourier transform is complex. dtype=... is accepted as an alias for consistency with the non-Hermitian GPU entry points. ComplexF32 is faster, while ComplexF64 is safer at tight cutoffs on large systems (a warning is emitted for ComplexF32 with cutoff < 1e-6).
The other keyword arguments are identical to the TBHamiltonian overload of get_bands (the default num_x = 60 is clamped in 1D to the momenta of the window, as there); as in get_bands(H, Ncheb, ω_phys_vals), the dimension D is taken from H.geometry, which must be set. The return value is also identical: a plain Matrix{Float64} when no kpath is given, or a NamedTuple(Ak, ticks, labels) when a high-symmetry path is requested.
Usage:
using CUDA
res = TensorBinding.get_bands_gpu(H, 500, omega;
kpath=[:G, :M, :Kp, :G], kpath_lattice=:honeycomb,
num_x=50, maxdim=200, type=ComplexF64, printinfo=true)
heatmap(1:size(res.Ak,2), omega, res.Ak; xticks=(res.ticks, res.labels))Normalisation: the package's KPM convention (see get_ldos_from_mun): the result is the spectral density per unit rescaled energy (ω − H.center)/H.scale times 1/π, so each momentum state integrates to 1/π; multiply by π/H.scale for physical units.
As in get_bands: in 2D one QFT runs over the linear index n = ix + iy·2^Lx, which mixes kx and ky, so 2D bands are not resolved by (kx, ky) and the kpath labels are not the points they name. 1D is not affected.
TensorBinding.chern_marker_gpu — Function
chern_marker_gpu(H::TBHamiltonian, xfunc=nothing, yfunc=nothing;
method=:mcweeny, fermi=0.0, l=nothing, Lambda=10,
Ncheb=300, maxdim=500, cutoff=1e-8,
Nel=nothing, quenched=true, dtype=ComplexF32,
printinfo=false) -> FunctionGPU-accelerated real-space Chern marker. Mirrors chern_marker but runs all MPO×MPO products (projector assembly and C1–C4 construction) on GPU.
Returns the same closure C_at(uc::Int) -> ComplexF64 as chern_marker.
Key differences from chern_marker
- All
apply/truncate!operations run on GPU tensors. dtype(defaultComplexF32) selects the GPU element type; the marker is intrinsically complex, so onlyComplexF32/ComplexF64are accepted. Usedtype=ComplexF64to avoid NaN from ComplexF32 eigendecompositions on large systems at tight cutoffs (a warning is emitted forComplexF32+cutoff < 1e-6).- For
method=:mcweenyandmethod=:sp2, only the initial guess (purification_initial_guess) is built on CPU; it is moved to GPU and the purification loop runs there. Formethod=:kpmthe whole projector is built on CPU (via_get_projector), then moved to GPU. chern_marker'ssequentialkeyword is not accepted; the quenched marker is always assembled from the C1–C4 MPOs.- The default
methodis:mcweeny(chern_markerdefaults to:kpm), andprintinfoprints progress.
All other keyword arguments are identical to chern_marker, including the deprecated spellings up to v0.1.1 (when this function was get_C_gpu): Λ for Lambda, Nchebychev for Ncheb and method=:KPM for :kpm; passing an old and a new spelling together is an ArgumentError (up to v0.1.1 Lambda silently won over Λ).
TensorBinding.get_scf_bands_gpu — Method
get_scf_bands_gpu(res, Ncheb, omega; kwargs...) -> (Ak, omega, ticks, labels)Compute spin-summed mean-field bands from a converged magnetic SCF result. This is deliberately separate from scf_magnetic_hubbard_gpu: it initializes from the CPU res.H_up/res.H_dn, then each get_bands_gpu call uploads once and keeps the Chebyshev/QFT accumulation on GPU, extracting only scalars. kwargs are passed unchanged to both get_bands_gpu calls (including type/dtype, complex only).
TensorBinding.get_scf_magnetization_gpu — Method
get_scf_magnetization_gpu(res; num_x=0, num_y=nothing, num_avg=1, x_start=1,
x_end=prod(dim(s) for s in res.H_up.sites),
x_groups=nothing, box_half=0, reduce=:point,
Lx=nothing)
-> (values, centers, groups, n_up, n_dn, reduce, stride_x, stride_y)Sample the converged magnetic SCF density matrices on GPU and extract only the final scalar values. If res carries GPU density MPOs from scf_magnetic_hubbard_gpu, they are reused directly; otherwise the CPU density MPOs are uploaded once. Each sampled point is evaluated in the same big-endian real-space convention as binary_to_MPS. values = (n_up .- n_dn) ./ 2, and the sampling plan is the 2D grid of spatial_sampling_plan (Lx position qubits along x, default half of them) unless x_groups is given.
Set reduce=:block to average over every unit cell in each coarse block by tracing the within-block position bits on GPU. In block mode, num_x and num_y must be powers of two, x_groups is rejected and box_half is ignored.
TensorBinding.scf_magnetic_hubbard_gpu — Method
scf_magnetic_hubbard_gpu(H0, U; initial_up=nothing, initial_dn=nothing,
background=0.5, Nel_up=H0.N ÷ 2, Nel_dn=H0.N ÷ 2,
fermi=0.0, scale=(H0.scale == 0.0 ? nothing : H0.scale),
purification_scale_padding=1.05, max_scf_iter=30,
scf_tol=1e-6, mix=0.4, maxdim=100, cutoff=1e-8,
purif_maxiter=40, purif_tol=1e-6,
type=ComplexF32, dtype=nothing, verbose=true)
-> NamedTupleGPU-accelerated two-channel collinear magnetic mean-field loop for the on-site Hubbard model. The SCF iteration keeps the density profiles, Hartree MPOs, Hamiltonian MPOs, density matrices, RMS checks, and mixing on GPU; CPU objects are built only for initialization and for the compatibility fields returned at the end.
H_up = H0_up + U·diag(n_dn − background)
H_dn = H0_dn + U·diag(n_up − background)U is a number (on-site) or an interaction MPO, which is then applied to n − background before the diagonal is formed.
There is no density_method keyword: the densities always come from McWeeny purification (grand-canonical at fermi); for particle-number-fixed SP2 use the CPU scf_magnetic_hubbard. Nel_up/Nel_dn only enter the particle_error recorded in history. A concrete purification scale is required so the GPU initial guess can be formed without estimating spectral bounds on CPU during the loop; it is multiplied by purification_scale_padding.
type (alias dtype; default ComplexF32) is the element type the Hamiltonians, densities and background profile are uploaded with; ComplexF64 is safer at tight cutoffs. A real type is accepted for a real H0, and the loop stays real (the Hartree MPOs are built with deltas of that type; up to v0.1.1 their ComplexF32 deltas made it complex after the first Hartree step). With a 32-bit type, real or complex, the Float64 coefficients of the Hartree, purification and mixing steps promote the loop to 64 bits after the first step, as they always did. ComplexF32 eigen-decompositions can NaN at very tight cutoffs: a warning is emitted for a 32-bit type with cutoff < 1e-5; the requested cutoff is used as-is.
The result carries converged, iterations, rms_error, history, the CPU fields rho_up, rho_dn, density_up_mpo, density_dn_mpo, H_up, H_dn, and their GPU counterparts rho_up_gpu, rho_dn_gpu, density_up_mpo_gpu, density_dn_mpo_gpu, H_up_mpo_gpu, H_dn_mpo_gpu.
Post-convergence observables are intentionally separate. Use get_scf_magnetization_gpu or get_scf_bands_gpu on the returned result when you want those GPU-accelerated diagnostics.
TensorBinding.get_exciton_cheb_convergence_gpu — Method
get_exciton_cheb_convergence_gpu(H, X, Ncheb_max;
maxdim_test=100, maxdim_ref=500, cutoff=1e-4,
type=ComplexF32, dtype=nothing,
printinfo=false)
-> NamedTuple
get_exciton_cheb_convergence_gpu(H, X_probes::AbstractVector{<:Integer},
Ncheb_max; kwargs...)
-> Vector{NamedTuple}Run two parallel GPU Chebyshev KPM recursions starting from |X,X⟩ = mpsexciton(X, H.sites): a reference recursion at maxdim_ref and a test recursion at maxdim_test. At each step n the two Chebyshev vectors φref^n and φtest^n are compared to yield:
errfidelityn = 1 − |⟨φref^n | φtest^n⟩|² / (‖φref^n‖² ‖φtest^n‖²)
which grows from 0 (perfect agreement) towards 1 as truncation errors accumulate.
Returns a NamedTuple with Float64 / Int vectors of length Nchebmax: n — Chebyshev index (1-based) muref — KPM moment ⟨X,X|Tn(H̃)|X,X⟩ from reference recursion mutest — KPM moment from test recursion deltamu — |muref − mutest| (moment discrepancy) errfidelity — infidelity 1 − fidelity as above mdimref — maxlinkdim of φref^n mdimtest — maxlinkdim of φtest^n normref — ‖φref^n‖ (should stay ≤ 1; growth indicates instability) normtest — ‖φtest^n‖
The Hamiltonian is rescaled internally: H̃ = (H − center·I) / scale, same as in getexcitonldosspatialgpu. All MPS live on GPU throughout, with element type type (alias dtype): ComplexF32 (default), ComplexF64, or Float32/Float64 for a real H. The vector method runs the single-probe method once per entry of X_probes, with the same keywords.
Use this to find the critical Ncheb beyond which maxdim_test is too small for a given system size — the threshold is where err_fidelity departs significantly from 0 (e.g. > 0.01 for a tight criterion, > 0.1 for a loose one).
TensorBinding.get_exciton_ldos_spatial_gpu — Method
get_exciton_ldos_spatial_gpu(H, Ncheb, ω_phys_vals;
Lx=nothing, num_y=nothing, reduce=:point,
X_list=nothing, X_groups=nothing, x_groups=nothing,
num_x=0, num_avg=1, x_start=1, x_end=H.N,
kernel=:jackson, lambda=4.0, eta=0.0, m_order=4,
maxdim=100, cutoff=1e-8,
type=ComplexF32, dtype=nothing,
verbose=false, printinfo=false,
return_maxlinkdim=false)
-> Matrix{Float64} (Nω × n_cols), or (; ldos, maxlinkdims) with return_maxlinkdim=trueGPU-accelerated spatial exciton LDOS A(X,ω) = ⟨X,X|δ(ω−H)|X,X⟩ via MPS Chebyshev KPM. One GPU Chebyshev recursion runs per probe position X (electron = hole = X, 1-indexed in 1:H.N) from |X,X⟩ = mpsexciton(X, H.sites); moments are scalars pulled to CPU.
1D sampling (default, Lx=nothing): num_x coarse positions over [x_start, x_end] with num_avg sub-positions per coarse cell averaged per output pixel. num_x ≤ 0 (the default) means every position (H.N columns) in 1D, and num_x = 8 on the 2D grid.
2D grid (Lx provided): positions are 1-indexed on the (Lx+Ly)-qubit quantics grid, encoded as X = ix + iy·2^Lx + 1 (row-major, 0-indexed). num_x × num_y coarse cells are sampled via spatial_sampling_plan with num_avg sub-positions per cell. Output columns are row-major over coarse cells (iy outer, ix inner).
X_list / X_groups / x_groups bypass the automatic plan and pass positions directly (X_groups and x_groups are aliases; pass at most one of the three).
kernel=:hodc selects HODC reconstruction (eta, m_order; eta=0 → 1/(Ncheb+1)). Other kernels: :jackson (default), :lorentz (lambda), :fejer, :dirichlet.
Use type=ComplexF32 (default, faster) or type=ComplexF64 (safer at tight cutoffs or on large systems where F32 eigendecomposition can produce NaN; a warning is emitted for a 32-bit type with cutoff < 1e-6), or Float32/Float64 for a real H. dtype is accepted as an alias for type for consistency with other GPU entry points.
return_maxlinkdim=true returns (; ldos = result, maxlinkdims) instead of just result, where maxlinkdims[j] is the maxlinkdim of the last Chebyshev vector of the last probe in column j (the χ the recursion hit under the given maxdim/cutoff); up to v0.1.1 it was the tuple (result, linkdims), which destructures the same way. Useful for cutoff/tolerance studies where χ is the observable.
reduce=:block is not available for the exciton LDOS. In the MPO-based LDOS functions (get_ldos_spatial_gpu), block averaging is a cheap O(1) partial trace of the diagonal MPS over the within-block position bits. The exciton LDOS has no diagonal MPS representation: each probe requires an independent Chebyshev recursion from |X,X⟩, so block averaging would cost O(blocksize) recursions per pixel — equivalent to computing every site. Use reduce=:point with `numavgfor light spatial averaging (each output pixel averagesnum_avg` nearby positions).
Normalisation: the package's KPM convention (see get_ldos_from_mun): with the convolution kernels the result is the spectral density per unit rescaled energy (ω − H.center)/H.scale times 1/π, so each state integrates to 1/π; multiply by π/H.scale for physical units. kernel=:hodc is normalised to 1 (multiply by 1/H.scale).
TensorBinding.get_nh_dos_grid_diag_trace_gpu — Method
get_nh_dos_grid_diag_trace_gpu(H, xlims, nx, ylims, ny, n;
scale=nothing, nh_scale_padding=1.05,
convention=:z_minus_H, block_placement=:post,
maxdim=100, cutoff=1e-8, dmrg_nsweeps=5,
dmrg_maxdim=[10, 20, 40], dmrg_linkdim=4,
dtype=ComplexF64, verbose=false, printinfo=false)
-> (xgrid, ygrid, Z)Grid companion to get_nh_dos_points_diag_trace_gpu: evaluates it on the nx × ny grid over xlims × ylims and returns Z[iy, ix] at xgrid[ix] + im*ygrid[iy]. The source and block rows/columns keep their defaults.
TensorBinding.get_nh_dos_grid_gpu — Method
get_nh_dos_grid_gpu(H, xlims, nx, ylims, ny, n;
scale=nothing, nh_scale_padding=1.05,
convention=:z_minus_H, block_placement=:post,
n_random=10, seed=42, maxdim=100, cutoff=1e-8,
dmrg_nsweeps=5, dmrg_maxdim=[10, 20, 40], dmrg_linkdim=4,
dtype=ComplexF64, verbose=false, printinfo=false)
-> (xgrid, ygrid, Z)GPU stochastic non-Hermitian KPM spectral-weight grid. This mirrors nh_spectrum_grid(...; mode=:stochastic): for each complex point z = x + im*y, the non-Hermitian Hamiltonian is hermitized on CPU, then the dual-chain stochastic MPS recurrence runs on GPU. Only scalar moments are copied back to CPU. Z[iy, ix] is the value at xgrid[ix] + im*ygrid[iy].
One universal scale from nh_kpm_scale (scale, nh_scale_padding, dmrg_*) is used for every point; one random-number generator (seed, or the global RNG for seed=nothing) is shared by the whole grid. dtype is the GPU element type, complex only: ComplexF64 (default) or ComplexF32 (warned below cutoff = 1e-4).
The integer n follows the existing NH convention: the partial recurrence runs to order 2n.
TensorBinding.get_nh_dos_points_diag_trace_gpu — Method
get_nh_dos_points_diag_trace_gpu(H, z_points, n;
scale=nothing, nh_scale_padding=1.05,
convention=:z_minus_H, block_placement=:post,
point_ids=nothing, maxdim=100, cutoff=1e-8,
dmrg_nsweeps=5, dmrg_maxdim=[10, 20, 40],
dmrg_linkdim=4, dtype=ComplexF64,
source_row=2, source_col=1,
block_row=2, block_col=1,
verbose=false, printinfo=false)
-> Vector{Float64}Deterministic GPU NH KPM at an explicit list of complex energies. For each z, the hermitized NH problem is built on CPU, then the online MPO-MPO recurrence runs on GPU and evaluates the total trace through diagonal extraction plus a GPU-resident all-sites sum. This avoids stochastic probes.
The integer n follows the NH convention used elsewhere in this file: the partial recurrence runs to order 2n. The scale keywords are those of get_nh_dos_grid_gpu; dtype is complex only (ComplexF64 default, or ComplexF32). source_row/source_col select the block of the NH source term and block_row/block_col the block whose diagonal is traced; point_ids only labels the progress output.
TensorBinding.get_nh_dos_points_gpu — Method
get_nh_dos_points_gpu(H, z_points, n;
scale=nothing, nh_scale_padding=1.05,
convention=:z_minus_H, block_placement=:post,
n_random=10, seed=42, seed_stride=1_000_003,
point_ids=nothing, maxdim=100, cutoff=1e-8,
dmrg_nsweeps=5, dmrg_maxdim=[10, 20, 40], dmrg_linkdim=4,
dtype=ComplexF64, verbose=false, printinfo=false)
-> Vector{Float64}GPU stochastic NH KPM at an explicit list of complex energies. This is the array-job companion to get_nh_dos_grid_gpu: each z_points[j] is independent, so production scripts can split a large grid over many GPUs and concatenate the long-form CSV outputs afterward. The scale and dtype keywords are those of get_nh_dos_grid_gpu.
When seed is an integer, each point uses a deterministic seed seed + seed_stride * point_id, where point_id defaults to the local point index. Supplying global flattened grid indices as point_ids makes stochastic samples reproducible independent of how the grid is tiled.
TensorBinding.get_nh_density_trajectory_gpu — Method
get_nh_density_trajectory_gpu(H, rho0; nsteps, dt, sample_every=1,
num_x=0, num_avg=1, reduce=:point,
x_start=1, x_end=nothing, x_groups=nothing,
maxdim=200, cutoff=1e-8,
truncate_intermediates=true, dtype=ComplexF32,
printinfo=false, verbose=false)
-> (density, times, centers, groups, maxlinkdims)GPU RK4 evolution of a density matrix under a static non-Hermitian Hamiltonian using d rho/dt = -i(H rho - rho Hdagger). H may be a TBHamiltonian or an MPO; rho0 may be a CPU or GPU MPO. The Hamiltonian and density matrix are uploaded once and the RK4 loop stays on GPU. At every sampled time, the diagonal of rho(t) is extracted on GPU and only scalar values at the requested groups are copied back to CPU. nsteps and dt are required; samples are taken every sample_every steps and at the last step.
dtype is the GPU element type, complex only: ComplexF32 (default) or ComplexF64; an MPO that is already on GPU keeps the type it was uploaded with. The RK4 step (rk4_step_dm_nh_gpu) uses step coefficients of the precision of the density matrix on GPU (ComplexF32 or ComplexF64).
Sampling follows the 1D spatial_sampling_plan convention: use num_x=0 to sample all sites, or set num_x to a smaller number for coarse production output. num_avg > 1 averages a few sub-points per sampled spatial bin in :point mode. With reduce=:block, num_x must be a power of two and each output value is the GPU block average over a contiguous interval of size 2^L / num_x. x_end=nothing means the last site.
TensorBinding.get_state_amplitude_trajectory_gpu — Method
get_state_amplitude_trajectory_gpu(H, psi0; nsteps, dt, sample_every=1,
num_x=0, num_avg=1, reduce=:point,
x_start=1, x_end=nothing, x_groups=nothing,
component=:real, pointavg=:complex,
normalize_each_step=false,
maxdim=200, cutoff=1e-8,
reverse_step=true, outputlevel=0, nsite=2,
dtype=ComplexF32, printinfo=false,
verbose=false)
-> (amplitude, times, centers, groups, norms, maxlinkdims)GPU TDVP evolution of a single-particle MPS state under the physical Hamiltonian H. ITensorMPS.tdvp(operator, t, init) computes exp(t * operator) * init (generator form), so the operator passed to tdvp is -im * H, which implements the Schrödinger evolution dψ/dt = -im * Hψ; therefore a loss term -im * Γ (Γ >= 0) damps the norm, matching evolve_with_tdvp(H::TBHamiltonian,...) on CPU and the NH RK4 convention dρ/dt = -i(Hρ - ρH†). H may be a TBHamiltonian or an MPO. The Hamiltonian and initial state are uploaded once, the TDVP loop stays on GPU, and only sampled scalar amplitudes are copied back to CPU. nsteps and dt are required; nsite, reverse_step, outputlevel and normalize_each_step are passed to tdvp (with the last, tdvp renormalizes the state after every step). reverse_step is true by default, as in evolve_with_tdvp; it was false up to v0.2.0, which is wrong at O(dt) per step and now warns.
The returned amplitude matrix has rows = sampled positions and columns = sampled times. By default it stores real(<x|psi(t)>); component may be :real, :imag, :abs, :abs2 or :probability (the same as :abs2).
Sampling follows spatial_sampling_plan in 1D. reduce=:point samples representative positions or explicit groups; pointavg sets how a group is averaged: :complex (default) averages the complex amplitudes and then takes component, while :abs/:abs2 average |ψ|/|ψ|² site by site (then component is not applied). reduce=:block returns the block-averaged complex amplitude over contiguous intervals, then takes component.
dtype is the GPU element type, complex only: ComplexF32 (default) or ComplexF64; an MPS/MPO that is already on GPU keeps the type it was uploaded with.