Skip to content

v0.2.1: bug fixes (TDVP reverse_step, BdG hole block, size-aware cutoffs) - #82

Merged
TiagoAntao2 merged 22 commits into
mainfrom
fixes
Nov 13, 2026
Merged

TiagoAntao2 merged 22 commits into
mainfrom
fixes

Conversation

@mousanouar

Copy link
Copy Markdown
Member

Bug fixes found after v0.2.0, prepared as v0.2.1: Project.toml is bumped and the CHANGELOG section is dated, so merging this PR is the release, which is then registered from the merge commit. The v0.2 API is unchanged. Four fixes change numbers; each is listed under Changed results in CHANGELOG.md with the golden cases it regenerates (only the TDVP one regenerates any). Everything else adds an opt-in feature or corrects documentation. Each fix is its own commit with its own test.

Changed results

  • TDVP state evolution defaults to reverse_step=true (tdvp_evolve, evolve_with_tdvp, evolve_with_tdvp_timedep, get_state_amplitude_trajectory_gpu, and the reference step of check_tdvp_vs_U_mpo).

    • With false, TDVP skips the backward evolution of the bond tensor and counts terms of H twice, so each step is wrong at O(dt): one step of dt = 0.05 on a full-rank 3-site state was off by 0.07, against 1e-15 with the backward step.
    • build_tdvp_propagator_mpo and ITensorMPS already default to true. Passing reverse_step=false reproduces the old numbers and warns once.
    • Regenerated: 10 TDVP cases in test/data/dynamics_golden.jl and 5 state_traj_* cases in test/data/gpu_golden.jl.
  • The BdG hole block is −H*. In the package's Nambu basis (c↑, c↓, c†↑, c†↓) with singlet pairing iσ_y ⊗ Δ, the builders made τ_z ⊗ H, whose hole block −H is wrong whenever H has imaginary entries (a Zeeman field along y, Peierls phases, complex hoppings).

    • Affected: add_superconductivity!, bdg_hamiltonian, bdg_spin_hamiltonian, the equal-spin triplet BdG of the SCF, and add_zeeman!/add_soc! after the doubling.
    • They now build P_p ⊗ H + P_h ⊗ (−H*). A real H keeps the one-term τ_z ⊗ H, so real-H results are bit-identical and no golden case moves.
  • build_K/dmrg_spectral: cutoff_K defaults to min(1e-8, 1e-4·η⁴, 0.1·r²/D²), D the dimension of the site space and r = min(1, ‖H‖²/‖H − ω‖²).

    • The cutoff is relative, so the fixed 1e-8 dropped the η² I term at small η, and in large systems the terms carried by a few matrix elements: on an open chain ⟨0|K|0⟩ was 2.01 instead of 1.01 from L = 13 at ω ≈ 0, and from L = 12 at ω = 1.7t.
    • The default is unchanged near the band centre for η ≥ 0.1 up to L = 11. A clean chain now keeps K within 5e-7 for |ω| ≤ 5t. Terms weak next to the rest of H (on-site potentials of a few t) still need an explicit cutoff_K; the docstring gives values.
  • The Hamiltonian builders' truncation cutoff depends on system size. Their relative 1e-8 dropped terms carried by a single matrix element in large systems, such as the bond across the middle of a 1D chain, 2^(L-1) - 1 → 2^(L-1):

    • "chain_1d", "uniform", "aah" and "ssh_sublattice" lost it at L = 26 ("ssh" at L = 28), and from L = 28 the chain was cut every 2^26 sites;
    • "custom" with nearest-neighbour hops threw;
    • add_onsite! and the other term adders, the non-Hermitian ones included, cut a correct chain again;
    • the chain MPO itself (kinetic_1d_nn, a fixed 1e-12) lost the bond at L = 39–40.

    The default is now min(1e-8, 0.1/D) in get_Hamiltonian, the term adders and the 1D builders, and in the hard-coded truncations inside hopping2MPO, qtci_matrix_to_MPO and two presets; the kinetic sums use min(1e-12, 0.1/D). The hermitization of non-Hermitian Hamiltonians scales it by min(1, ‖H‖²/‖zI − H‖²), since the block grows with |z|. In 2D, where a long carry repeats along a whole row or column, D is taken along the longer side, so 2D results keep 1e-8. The default equals 1e-8 up to D = 2^23, so smaller systems build the same MPOs bit for bit and no golden case moves. Every 1D model now keeps all its hops at L = 26–30 (the chain MPO at L = 40). A bond that is weak next to strong terms (on-site potentials beyond ~4t, a 3× stronger bond) is not protected, as it was not before; the docs say so. An explicit value is used as given and warns once when it is risky. add_tjunction! caps its default at a tenth of the junction's weight, so a weak junction is kept (t_j = 0.02t at L = 16 was removed); for t_j² < 1e-7·2^L·t² this moves the default below 1e-8 at any size.

Added

  • Diagonal profiles from vectors: get_mps, get_mpo, get_diagonal_mpo, add_onsite! and add_zeeman! accept the values as a vector, compressed by TT-SVD (exact up to tol, no RNG).
  • check keyword for the QTCI profiles (default false). check=true verifies the build against f and replaces a wrong one.
  • add_soc! keyword boundary for the Rashba term (:periodic by default, as before, or :open).
  • --only for the dynamics and GPU golden generators, which reruns the named cases and keeps every other stored entry; unknown arguments are an error.

Fixed and documented

  • add_onsite! threw on a spinful or BdG Hamiltonian. It now acts as the identity on the spin and as τ_z ⊗ V on the Nambu index, the same matrix as adding it before add_spin!/add_superconductivity!. The scftopo golden case that pinned the old error now pins the value.
  • Golden suites run with one BLAS thread (runtests.jl pins it). At OpenBLAS's default thread count, 11 golden tests failed with no code change. One near-zero GPU Chern marker is pinned at atol = 1e-6.
  • 2D get_bands/get_bands_gpu, get_qpi and the cheb2d k-diagonals are not 2D Fourier transforms: one QFT runs over the linear index, mixing kx and ky. The docstrings now warn about it; the code is unchanged.
  • Docstrings: the add_soc! Rashba term, the get_dos_stochastic normalisation, the KPM 1/π convention and Jackson moment count (new Conventions section on the Solvers page), the spin-operator factors, the qubit-operator naming, the shift direction, and the bdg_spin_hamiltonian basis.
  • using TensorCrossInterpolation → import.
  • The TDVP exactness test runs without truncation (with the default cutoff it failed on Julia 1.10, whose OpenBLAS rounds one singular value below it).

Testing

  • Full suite with the golden suites and GPU tests (Julia 1.12.3, Windows, RTX 4060): all 19,501 tests pass, including the 4,127 golden tests and the GPU tests.
  • CI reproduction, Pkg.test() with CI=true (golden suites skipped, --check-bounds=yes, GPU tests skipped as on GitHub): Julia 1.12.3, 15,328 pass; Julia 1.10.13, 15,334 pass.
  • Docs build (makedocs, no warnings): passes.
  • Not run locally: Julia 1.11 and pre.

After merging

Register v0.2.1 from the merge commit, as for v0.2.0: the Registrator bot command as a comment on that commit, not on this PR, with the release notes in the same comment. TagBot then tags the release.

🤖 Generated with Claude Code

mousanouar and others added 22 commits November 12, 2026 21:11
…rection

The spin table of prepend_spin (and the comment above _SPIN_OPS) now says
that :Sx, :Sy and :Sz are spin-1/2 operators (1/2 sigma) while :iSy and :miSy
are the full +-i sigma_y, not i S_y.

The qubit operators state their naming: sigma_plus = |0><1| lowers the bit
value (spin naming with |0> = up), so the +1 shift in pairingNNN carries
sigma_minus on the bit it raises; the companion paper (arXiv:2607.00991,
App. A) names the operators by the bit value, so its tau^+ is sigma_minus.

The shift-MPO section header claimed (Q f)(x) = f(x + q); build_shift_mpo maps
|n> to |n + q>, so on amplitudes (Q psi)(x) = psi(x - q).

Comments and docstrings only; no code changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
add_soc!(type=:rashba) built its term from the cyclic +-1 shifts, so on an
open chain (the default of get_Hamiltonian("chain_1d")) it added a Rashba
bond between the last and the first site that the kinetic term does not
have. boundary=:open (or :obc) drops that bond. The default :periodic keeps
the v0.2.0 term and code path, so the golden cases are unchanged. The keyword
goes through the package's boundary parser, so an unsupported value is an
error for every SOC type, before H is modified.

On a 2D Hamiltonian (H.Lx < H.L) the term couples neighbours along the linear
position index, across the row ends and with no y bonds; add_soc! now warns
there. A 2D Rashba term is still missing.

The docstring gave the term as lambda (S_y K_u - S_y K_d), which is not
Hermitian; it now gives the lambda i sigma_y (K_u - K_d) that the code builds.

bugfix_soc_boundary.jl checks both boundaries against dense references.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With the convolution kernels every Hermitian KPM spectrum is divided by
pi^2 Ncheb sqrt(1 - w^2): it is the spectral density per unit rescaled energy
times 1/pi, so one state integrates to 1/pi and pi/H.scale converts to
physical units. kernel=:hodc carries the delta normalisation (integral 1),
so switching kernel rescales the output by pi. Only get_ldos_from_mun said
so. A Conventions section on the Solvers page and a Normalisation note in
the docstrings of the LDOS, DOS, band, exciton and QPI entry points (CPU and
GPU) now say it, with a link to get_ldos_from_mun.

The Conventions section and get_ldos_from_mun also say that kernel=:jackson
with Ncheb moments is the textbook Jackson kernel for Ncheb - 1 moments (the
last weight is zero), while the NH KPM and the cheb2d bubbles use all N.

get_dos_stochastic called its normalize=false output Tr[delta(w - H)]; with
the convolution kernels it is that divided by pi, per unit rescaled energy.

Docstrings and docs only. A local makedocs run resolves every new
cross-reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`using TensorCrossInterpolation` brought TCI's exports into the module,
where `contract` and `evaluate` became ambiguous names. Nothing called them
bare, but a future bare call would have thrown. `import
TensorCrossInterpolation` keeps the module name for the four qualified calls
(core/Hamiltonian.jl, core/Utils.jl) next to the TCI alias.

The four call sites give the same matrices as v0.2.0. The full test suite
passes apart from the golden mismatches that the v0.2.0 sources show on this
machine too (scftopo 7, RPA 4, GPU 1, identical numbers), and the docs build.
Ticks the item in docs/dev/REORGANISATION_TODO.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r absolutely

The 12 golden failures found at v0.2.0 were not code changes. The generators run
with OPENBLAS_NUM_THREADS=1, but runtests.jl left OpenBLAS at its default (12
threads here), and threaded sums amplified through small-maxdim truncations moved
11 tests: bubble_kagome_kpm and rpa_charge_kagome by up to 6e-3 (relative 2-5),
haydock_bubble_chain3_kpm by 2e-5, the scftopo Chern markers by 5e-8. With one
BLAS thread all of them match the stored data exactly, at 0833629, 6d5eed0 (the
last src commit before the release) and on this branch.

runtests.jl now sets one BLAS thread around the characterization block and restores
the count afterwards. The remaining GPU case, chern_honeycomb_nnn_sublattice_geometry_c64,
is a near-zero marker (norm 9e-5) that McWeeny iterates GPU rounding into; it moved by
1e-7 since the data were generated (CUDA runtime 13.0 then, 13.4 now) and is pinned at
atol = 1e-6. All 4127 golden tests pass with one thread; no data file changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
tdvp_evolve, evolve_with_tdvp, evolve_with_tdvp_timedep,
get_state_amplitude_trajectory_gpu and check_tdvp_vs_U_mpo (tdvp_reverse_step)
defaulted to reverse_step=false, which skips TDVP's backward evolution of the bond
tensor and counts terms of H twice: every step is wrong at O(dt). On a full-rank
state of a 3-site chain, one step of dt = 0.05 was off by 0.07 (0.21 after three);
with the backward step TDVP matches exp(-iH dt) to 1e-15 (2-site and 1-site).
build_tdvp_propagator_mpo has defaulted to true since 0.1.1, as ITensorMPS does.
Passing false reproduces the old results and warns once per function. The heatmap
example uses true as well.

Changed results, golden data regenerated:
- dynamics_golden.jl: the ten cases that run TDVP (tdvp_evolve_*, evolve_with_tdvp_*,
  basis_amplitude and phase_aligned_distance, whose states come from tdvp_evolve),
  moved by 0.04 to 0.26. The rerun also moved the three krylov_green cases by 5e-14
  (rounding; Krylov.jl does not use TDVP), whose stored lines were kept.
- gpu_golden.jl: the five state_traj cases, rerun with the generator's new --only
  option, which keeps the stored entries of every other case (a full rerun moves
  every GPU value by rounding). The generator now records the working-tree src/ tree,
  as the dynamics generator does; the header names 79984c1, this commit's src/.

New test: one TDVP step and three steps (fixed and time-dependent H) against a
Taylor-series exp(-iHt) on a full-rank state, the warnings, and the size of the
reverse_step=false error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
In the Nambu basis (c_up, c_dn, c+_up, c+_dn) of the package, the one in which the
singlet pairing is i sigma_y (x) Delta, the hole block of a normal-state term H is -H*.
add_superconductivity!, bdg_hamiltonian, bdg_spin_hamiltonian and the equal-spin
triplet BdG of the SCF (_triplet_equalspin_bdg) built tau_z (x) H, whose hole block -H
is wrong whenever H has imaginary entries (a Zeeman field along y, Peierls phases,
complex hoppings); add_zeeman! and add_soc! on a Hamiltonian that already had a Nambu
index lifted their terms the same way. An L = 2 spinful chain with h = 0.3 along y and
Delta = 0.25 had a BdG spectrum off by 1.4e-2.

Two helpers in core/AuxDOF.jl build Pp (x) M + Ph (x) (-M*) (dag conjugates each
tensor and keeps the primes): _nambu_normal_block for the doubling, _lift_normal_term
for a term added afterwards. A real M (every imaginary part exactly zero) still gets the
one-term tau_z (x) M of v0.2.0, so every result with a real Hamiltonian is unchanged bit
for bit: all 4127 golden tests pass against unchanged data. The bdg_spin_hamiltonian
docstring named the basis (c_up, c_dn, c+_dn, -c+_up), in which its i sigma_y pairing
would vanish; it now names the basis the code uses.

New test (22 checks): dense BdG matrices against [H D; D' -conj(H)] for Zeeman fields
along x, y, z, for bdg_hamiltonian and bdg_spin_hamiltonian with complex kinetic terms
and for the triplet SCF builder with a complex H0; a Zeeman or y-SOC term added after
the doubling gives the same matrix as before it; the real path is the tau_z build.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
cutoff_K is relative to the squared norm of each sum and product in build_K, and the
eta^2 I term is the smallest part of K = (H - omega)^2 + eta^2: with the fixed default
1e-8 the truncation dropped most of it at small eta (a 5-qubit chain with a cos
potential, omega = 0.05, eta = 1e-2: ||Delta K|| = 9.7e-5 against the dense K, i.e.
about eta^2). Zero-mode work had to pass 1e-14 to 1e-20 by hand.

build_K and dmrg_spectral now default to cutoff_K = nothing, resolved to
min(1e-8, 1e-4 eta^4): exactly 1e-8 for eta >= 0.1, and 1e-8 for eta = 0, where K has
no eta^2 term; results there are unchanged bit for bit (the dynamics golden cases, at
eta = 0.1 and 0.2, pass unchanged). An explicit cutoff_K >= eta^4 is used as given and
warns once. The default assumes eigenvalues of H - omega of order one, as the docstring
says.

New test: ||Delta K|| < 1e-3 eta^2 at eta = 1e-2 with the default, the old value and its
warning, and identical K at eta = 0.1, 0.3 and 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…files

get_mps runs QTCI from the first point and five random pivots (global RNG) and checks
nothing, so get_diagonal_mpo, add_onsite! and add_zeeman! could lose a narrow feature
or throw on a profile that vanishes almost everywhere (L = 10: a 4-site box on a 0.1
background lost for 3 of 5 seeds; a single nonzero site threw "maxsamplevalue is
zero!" for 5 of 5).

Added, with no change to existing calls:
- a vector of the 2^L values (v[n+1] at the 0-indexed n) for get_mps, get_mpo,
  get_diagonal_mpo, add_onsite! and add_zeeman!, compressed by TT-SVD (cutoff tol^2/2^L
  per bond, so every entry within about sqrt(L) tol max|v|): exact, no sampling, no RNG;
- check (default false) for get_mps, the one-argument get_mpo, get_diagonal_mpo and
  add_onsite!: the QTCI build is kept when no checked entry is off by more than
  sqrt(tol) max|f|. Up to 2^20 points every point is checked and a wrong build (or a
  throw) is replaced by the TT-SVD of the values; above, a sample (ends, carry
  boundaries 2^k-2 .. 2^k+1, a golden-ratio stride of 4096 points) is checked and a
  wrong build is redone from the missed points as pivots without random ones, then
  checked again (an error if it still fails). A passing build is returned unchanged,
  as in hopping2MPO(...; check=true). get_mpo with a two-argument f rejects check=true
  and points to hopping2MPO.

New test (31 checks): TT-SVD exactness for a box, a single site, a complex profile and
L = 1; check=true at the five seeds that failed before, on the box and on the single
site; a passing build unchanged; the zero profile; add_onsite! and add_zeeman! with
vectors; the sampled path at L = 21 with a box at the carry boundary 2^20.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to rounding

The generator header said a rerun reproduces the data file byte for byte. The rerun
for 8d4eb10 also moved the three krylov_green cases by up to 5e-14 although
src/solvers/Krylov.jl had not changed; their stored lines were kept. The header now
says so and asks for the same after every rerun, so that the data diff shows only the
cases a change moves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An independent review of daff2aa..9795a20 confirmed the BdG, TDVP and TT-SVD numerics
(including a full Fock-space check of the BdG spectrum) and found the following, each
reproduced here:

- build_K: the norm of K grows like 2^L, and zip-up's apply(H - w, H - w) drops a term
  that lives on a few sites once cutoff_K exceeds about 0.3*4^-L. On a uniform open chain
  <0|K|0> = 2.01 instead of 1.01 (the end bond lost) at L = 16 with the old and current
  default 1e-8 (eta >= 0.1) and at L = 20 with the new default at eta = 0.01; fine at
  L = 12. A cutoff below the bound keeps K exact (1e-10 at L = 20 and 24 with the default
  divided by 2^L). The default is unchanged (a size-aware default moves eta >= 0.1
  results, a decision for later); build_K now warns once when cutoff_K > 0.3/D^2 and the
  docstring states the limit.
- The vector TT-SVD and the dense readout built an order-L ITensor, so ITensors printed a
  contraction warning with a backtrace from L = 14 and compiled per tensor order (14-45 s
  first calls). Both now work on plain arrays site by site (LinearAlgebra.svd, matrix
  products); L = 20 takes 0.3 s and prints nothing. _mps_entry reads many entries from
  precomputed site arrays.
- Abstractly typed vectors (Vector{Any}) failed in float(eltype); the element type is now
  promoted from the entries.
- check=true above 2^20 points cannot see a feature between its sampled points (as
  documented); an @info now says so once.
- check_tdvp_vs_U_mpo(...; tdvp_reverse_step=false) warns under its own name and keyword.
- The BdG helpers build -M*, the hole block of a Hermitian term; for a non-Hermitian term
  it would be -M^T, which neither build gives. Documented as a requirement.

Tests: the size warning and the exact K below the bound at L = 16; check_tdvp's warning;
Vector{Any}/Vector{Real} profiles; an L = 16 vector with nothing printed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…/D^2)

cutoff_K is relative to the squared norm of each sum and product, and the norm of
K = (H - omega)^2 + eta^2 grows with D, the dimension of the site space (2^L for
qubits). The zip-up product apply(H - omega, H - omega) therefore drops a term that
lives on a few sites once cutoff_K exceeds about 0.5/D^2: on an open chain
(omega = 0.05, eta = 0.1) the end bond is kept at 0.3/D^2 and lost at 0.7/D^2 to 1/D^2
(L = 12-16), and the v0.2.0 default 1e-8 gave <0|K|0> = 2.01 instead of 1.01 from
L = 13 on, K wrong by t^2 at both ends (the eta-only default min(1e-8, 1e-4 eta^4) from
L = 20 at eta = 0.01).

The default adds 0.1/D^2: 1e-8 for eta >= 0.1 (and eta = 0) up to L = 11, so those
results are unchanged bit for bit (the golden DMRG cases are at L = 3 and pass
unchanged); from L = 12 on it is smaller. On an open chain with an exact H it keeps five
probed elements of K (both ends, bulk, <0|K|2>, the wrap) to 2e-7 up to L = 30 (2.2e-8
with the untruncated kinetic_1d_nn); the build costs the same (bond dimension 6, under
0.1 s). With H from get_Hamiltonian("chain_1d") K is wrong again from L = 26, because
that MPO is truncated at a relative 1e-8 itself and loses the hop across the middle: a
separate, pre-existing issue, not changed here. The size warning (cutoff_K > 0.3/D^2)
stays; the docstring replaces the "Large systems" admonition by the three bounds of the
default.

Test: the default at L = 16 keeps the end bond without a warning; an explicit 1e-8
warns and loses it; _default_cutoff_K at L = 5, 11, 12, 16.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, 0.1/D)

The builders and term adders truncate with a cutoff relative to the squared norm of
the MPO, ||H||^2 ~ z D t^2 for a site space of dimension D, so a fixed 1e-8 drops a
term carried by a single matrix element once D is large. The bond across the middle
of a 1D chain, 2^(L-1) - 1 -> 2^(L-1), whose carry flips every qubit, is such a term:

- get_Hamiltonian("chain_1d") (truncate! at tol = 1e-8) lost it at L = 26, gained a
  wrap-around element of -0.036, and from L = 28 lost every hop flipping 27 bits or
  more, cutting the chain every 2^26 sites (N/2 included);
- "uniform" and "aah" lost it at L = 26 through their own sum with the on-site term
  (cutoff = 1e-8 hard-coded in HUniform/HAAH) and hopping2MPO's final truncate!
  (also hard-coded); "ssh" at L = 28; "ssh_sublattice" lost two carry levels at L = 26;
- get_Hamiltonian("custom") with nearest-neighbour hops threw at L = 26: the sampled
  check of hopping2MPO caught the missing bond and the rebuild lost it again;
- add_onsite! (and every other term adder, which sum and truncate at tol = 1e-8)
  cut a correct chain again.

The default is now _default_mpo_cutoff(D) = min(1e-8, 0.1/D), which keeps every term
with at least one element of order the hopping (z <= 10) and equals 1e-8 up to
D = 2^23, so smaller systems build the same MPOs bit for bit (no golden case moves).
It applies to get_Hamiltonian and estimate_scale (tol), add_hopping!,
add_hopping_2D!, add_onsite!, add_spin! (cutoff), add_zeeman!, add_soc!,
add_superconductivity!, exciton_hamiltonian, Exciton_Hamiltonian (tol),
spin_hamiltonian, bdg_hamiltonian, bdg_spin_hamiltonian, ssh_sublattice_hamiltonian,
add_tjunction!, tjunction_hamiltonian (cutoff), and to the fixed truncations inside
hopping2MPO, qtci_matrix_to_MPO, HUniform and HAAH. A given value is used as given
and warns once (_mpo_cutoff) above 0.3/D; the middle bond of a chain is lost from
about 0.5/D. Where tol was also a QTCI tolerance ("custom", "haldane", two-argument
terms) a given tol still is, and the QTCI default stays 1e-8. The projected
quasicrystal spaces keep 1e-8 (not checked at large L); the 2D-only builders and the
solvers are not changed: in 2D a long carry repeats along a whole row or column, and
1e-8 kept every hop of square, hex, triangular, chern8, kagome and honeycomb lattices
at L = 26-30.

Audit (examples/nontracked/fixes_checks/builders_carry_audit*.jl): every 1D model keeps
all its hops at L = 26, 28 and 30, and add_onsite! keeps them at L = 26 and 28. The
chain MPO of kinetic_1d_nn itself loses the middle bond at L = 40 whatever the cutoff
(documented, not investigated).

Test: test/bugfix_large_L_cutoffs.jl (L = 26: chain with and without an explicit
1e-8, add_onsite!, "uniform", "aah", "custom"; the default and the warning threshold).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
add_onsite! built the potential on the position (and sublattice) sites only and added
it to H.mpo, which on a Hamiltonian with a spin or Nambu index threw "the input MPS or
MPO do not have the same site indices" (a function and a vector alike): the potential
had to come before add_spin! and add_superconductivity!. It now lifts the term with
_lift_normal_term, as add_zeeman! and add_soc! do: the identity on the spin, tau_z (x) V
on the Nambu index (the hole block -V* of _nambu_normal_block, i.e. -V for a real V),
the sublattice projector on a sublattice index, each on the side H.sites puts it. That
is the matrix the old order gave. A complex V on a BdG Hamiltonian is an error: it is
not Hermitian, and the BdG hole block -H* is only right for a Hermitian H. The
spinless and sublattice paths are unchanged; a layered Hamiltonian with spin or Nambu
still errors, as before.

Test: test/bugfix_onsite_aux.jl (L = 3 chain with the spin in front and behind, a
spinful BdG with a Zeeman field along y, the Kitaev chain, SSH with sublat = 1 and a
spin; each against adding the potential before; the complex-V error).

On a BdG Hamiltonian a complex value is rejected with that error whatever its form: a
complex number up front, function values as QTCI samples them (they used to reach the
real-valued QTCI build and stop there with an InexactError), vectors after their TT-SVD
build.

The scftopo golden case tbsystem/add_onsite!/spinful pinned the v0.2.0 error; it now
pins the value, kron(I2, H0 + 0.1 I) to 1.9e-15. The new entry was spliced into the
stored file: a full rerun of generate_scftopo_golden.jl moved only this entry, the count
of throwing cases (27 -> 26) and the two get_W KPM entries its header keeps at their old
values (2.3e-11 and 3.2e-11). Scftopo goldens 199/199.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A full rerun of generate_dynamics_golden.jl moves untouched cases by rounding (the
three krylov_green cases by up to 5e-14 in the rerun for 8d4eb10), so their stored
lines had to be restored by hand. `--only name1,name2,...` now reruns the named cases
and keeps the stored entries of all others, as generate_gpu_golden.jl does since
8d4eb10. The header keeps the previous generation lines and records the src/ tree
and the cases of the partial rerun; generation_lines also reads the header written
before this change, which had the "Regenerate only" note at the end of the Julia line
(a full rerun now puts that note on its own line). Unknown names, or kept cases with
no stored entry, are errors. As before, the script reloads the file, checks the round
trip and replays every case.

Checked: --only dmrg_build_K,tdvp_evolve_normalized changed only the header (both
cases reproduced exactly) and the replay passed 118/118; the data file was restored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
conjugate_by_qft applies one QFT over all position qubits, i.e. over the linear index
n = ix + iy 2^Lx (src/physics/qft/conjugation.jl), not QFT_x (x) QFT_y. In 2D the
k-group label (ky << Lx) | kx is then misread: its low Ly bits are the true ky and its
high bits the true kx, plus a shear of (label mod 2^Ly)/2^Ly grid steps (for Lx = Ly, ky
comes from the x bits and kx from the y bits). Checked on 2026-09-29 against dense
diagonalisation: along Gamma -> X an anisotropic 8x8 torus (tx = 1, ty = 0.3) follows the
ty band, and on 4x4 to 8x8 tori the off-diagonal part of the conjugated Hamiltonian is
0.5-0.7 of its diagonal in Frobenius norm (that part decays with size; the relabelling
and the shear do not). The kpath labels are therefore not the points they name. The
low-level get_bands, the TBHamiltonian method and get_bands_gpu now carry a warning
admonition; the code and every result are unchanged (1D is not affected). The fix, an
opt-in separable 2D transform (or plane-wave probes) beside the current path, is left
for a later release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test of 8d4eb10 compares TDVP on a full-rank 3-site state with the exact
e^{-iHt}|psi>, which reverse_step=true reproduces to 1e-15. It called tdvp_evolve,
evolve_with_tdvp and evolve_with_tdvp_timedep at their default cutoff = 1e-10, so the
two-site SVD could drop a singular value near the threshold: with Julia 1.10's
OpenBLAS (same package versions, same initial state) evolve_with_tdvp was off by
3.3e-9 after three steps and failed the 1e-10 bound, while 1.12 rounds the other way
(3e-15). With cutoff = 0 both give 1.7e-15 to 3.9e-15. The checks now pass
cutoff = 0.0; the bounds and the reverse_step=false comparison are unchanged.

Found by running the CI matrix's Julia 1.10 locally (juliaup, beside 1.12).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The norm of K = (H - omega)^2 + eta^2 grows with omega while the terms that live on a
few sites (the end bond of an open chain) do not, so the 0.1/D^2 of 722145c still lost
the end bond near the band edge: on a 14-qubit chain at omega = 1.7t and 2t, <0|K|0> was
off by 1 (found by the review of the branch; the loss threshold fits 0.5/(1 +
omega^2/2)^2/D^2 there). The size term is now 0.1 r^2/D^2 with
r = min(1, |H|^2/|H - omega|^2), computed exactly from |H|^2, tr H and D (two MPO inner
products). As r <= 1 the default never exceeds the previous one, and it is unchanged near
the band centre: the golden DMRG cases (L = 3) pass unchanged. A clean chain now keeps K
within 5e-7 for |omega| <= 5t at L = 14, 20 and 26.

Not covered, and now documented: terms weak next to the rest of H. With an on-site
potential V cos(.) part of K is lost from V ~ 2t (0.17 at V = 2t on 14 qubits), as with
1e-8; cutoff_K = 1e-2/D^2 (V <~ 3t) or 1e-3/D^2 (V <~ 5t) is needed there. The size
warning compares with 0.3 r^2/D^2.

Test: the end bond at omega = 2 on 14 qubits with the default; _default_cutoff_K with r.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…weak T-junctions

Follow-up to 37fa32e after the review of the branch.

- 2D: a long carry repeats along a whole row or column, so the term adders (through
  _cutoff_dim), the 2D presets and the multi-atom lattices take D along the longer side.
  2D results keep 1e-8 at every usual size, and an explicit 1e-8 no longer warns there:
  get_valley_operator on a 12x12 honeycomb (D = 3.4e7) warned about "the bond across the
  middle of a 1D chain". The multi-atom and 2D preset builders take D from Lx and Ly, not
  from the keyword L (a mismatched L gave another size's cutoff).
- The non-Hermitian adders (add_nh_onsite!, add_loss!, nh_nonreciprocal_hopping_mpo,
  add_nh_nonreciprocal_hopping!, add_nh_skin_hopping!) and the hermitization
  (hermitized_hamiltonian, hermitize) still summed at a fixed 1e-8 and cut an L = 26 chain
  again (middle bond 3e-31 after add_nh_onsite!); they now take the same default.
- kinetic_1d_nn, kineticNNN and shift_hopping_mpo summed at a fixed 1e-12, which cut the
  middle bond at L = 39 (one direction: a non-Hermitian chain) and 40. They now use
  min(1e-12, 0.1/D), unchanged up to L = 36. This was the "loss at L = 40 whatever tol"
  that 37fa32e documented as not investigated.
- add_tjunction!: the junction is a single-site term of weight ~(t_j/t)^2/2^L, and a
  relative cutoff above it left three decoupled chains (t_j = 0.02t at L = 16 with 1e-8,
  t_j <= 0.18t at L >= 22 with 0.1/D). Its default now stays a tenth below that weight.
- One warning per call: add_zeeman! and add_soc! attach the spin through _attach_spin! with
  their own resolved cutoff, and get_Hamiltonian("ssh_sublattice") builds through
  _ssh_sublattice_hamiltonian, instead of resolving and warning twice.
- The hermitization's default also scales with r = min(1, |H|^2/|zI - H|^2), as the
  block grows with |z|: with 0.1/D an L = 26 chain kept its middle bond as 0.92/0.08 at
  z = 3 and 1/1.7e-7 at z = 4 (now exact). The non-Hermitian KPM entry points pass their
  own cutoff to it, which is documented.
- pairingNNN summed at a fixed 1e-12 like kineticNNN; it gets the same min(1e-12, 0.1/D).
- add_tjunction!: the cap applies only when the junction has weight. With t_j = 0 a zero
  cap kept every noise vector (bond dimension 200 at L = 10).
- Docs: the default keeps a bond with |t|^2 >= <h^2>/10, <h^2> = |H|^2/D. It does not keep
  a bond that is weak next to the rest of its rows (on-site terms beyond ~4t, a 3x
  stronger bond), and neither did 1e-8: "aah" with V = 6 at L = 26 and "ssh_sublattice"
  with d = 0.8 at L = 25 lose it. get_Hamiltonian's "Large systems" section, the
  MPOTools comment and the CHANGELOG say so. The source map and the file headers list the
  new calls into MPOTools and AuxDOF.

Test: test/bugfix_large_L_cutoffs.jl adds the non-Hermitian adder at L = 26, a single
warning from add_zeeman!, no warning for an explicit 1e-8 in 2D at L = 26, the chain at
L = 40, a weak and a zero T-junction, the hermitized chain at z = 4 and pairingNNN at
L = 40; the check on the explicit-1e-8 chain reads both
directions of the middle bond, since which one survives is up to the SVD's rounding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
generate_dynamics_golden.jl and generate_gpu_golden.jl only looked for "--only" followed
by a value. A mistyped option (--only=..., -only) fell back to a full regeneration, the
outcome --only exists to prevent; "--only a b" reran a without a word; a trailing
--only died with a BoundsError after the packages had loaded. Both now accept
--only a,b and --only=a,b, and stop with an error on a missing value or any other
argument (checked on seven argument lists).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ect its figure

get_qpi and get_bubble_diag_cheb2d(_svd, _tucker) take their momenta from the same
single QFT over the linear index as get_bands (QPI.jl, and cheb2d.jl through
conjugate_by_qft); get_qpi's docstring even told the user to reshape the output as a
(kx, ky) map. Both docstrings now carry the warning, and the CHANGELOG entry names them.

In get_bands, "50-72 % of the weight stays off the momentum diagonal" was the Frobenius
ratio of the off-diagonal to the diagonal part of the conjugated Hamiltonian on 4x4 to
8x8 tori, which decays with size, and "ky from the x bits" holds only for Lx = Ly. The
admonition now says what is misread at every size: the low Ly bits of the label are the
true ky, the high bits the true kx plus a shear.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bump the version to 0.2.1 and date the changelog section. 0.2.1 keeps the v0.2 API
(fixes and additive keywords only); the Changed results entries are bug fixes that
move numbers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mousanouar

Copy link
Copy Markdown
Member Author

The Julia pre failure is upstream: on Julia 1.14.0-alpha2, GenericLinearAlgebra 0.3.19 fails to precompile (it overwrites LinearAlgebra.lmul! for HessenbergQ; JuliaLinearAlgebra/GenericLinearAlgebra.jl#183). It reaches us through Quantics → SparseIR, and the fix for the 0.3 series is pending in JuliaLinearAlgebra/GenericLinearAlgebra.jl#186. The job fails before the tests run; this PR changes no dependencies.

@TiagoAntao2
TiagoAntao2 merged commit 120b1ad into main Nov 13, 2026
2 of 4 checks passed
mousanouar added a commit that referenced this pull request Nov 13, 2026
At L = 40 the chain MPO has norm ~1.5e6, and the kept middle bond carries rounding
noise of 4.6e-9 / 5.3e-9 on Windows (Julia 1.12) and 1.7e-8 on GitHub's Linux runner
with Julia 1.10, which failed the 1e-8 bound of the two L = 40 chain checks (CI of
PR #82). The noise is ~1e-14 at L = 26 and ~1e-12 at L = 34, so only the L = 40
checks (chain and p-wave pairing) change. A cut bond is off by 0.5 or more, so 1e-6
still catches what the test is for. Test-only change; no code or result moves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TiagoAntao2 added a commit that referenced this pull request Nov 13, 2026
Check the L = 40 bond elements to 1e-6 (CI 1.10 failure of #82); README quasicrystal bullet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants