Skip to content

Tests for Hamiltonian derivatives and long-range models - #493

Merged
lkdvos merged 9 commits into
mainfrom
bd/ACham-typo
Sep 26, 2026
Merged

lkdvos merged 9 commits into
mainfrom
bd/ACham-typo

Conversation

@borisdevos

Copy link
Copy Markdown
Member

This one took a while to debug since I don't really know how these Jordan MPOs work. I now understand a little better 😄

It turns out two things have to occur simultaneously for this to have been noticed. First, the scalartype of the Hamiltonian and the state must mismatch, such that the constructor of the AC Hamiltonian doesn't get fast-forwarded to the inner constructor but lands on the fallback one with the typo. Second, the Hamiltonian needed to not have the ending block while also have the finishing one. Since I was playing around with something semi-long range, I came across this, which makes sense. Nearest-neighbor Hamiltonians will always have B.

Coincidentally, we never caught this in the tests because we don't look at long-range Hamiltonians. So I added that to the tests, along with fairly extensive tests on the derivatives themselves directly. Some might be overkill, but better safe than sorry. Locally the performance of these long-range Hamiltonians is notably terrible (see #459)

I also discovered the changelog, so I decided to add to that :)

Comment thread test/algorithms/groundstate.jl Outdated
@codecov

codecov Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@borisdevos

Copy link
Copy Markdown
Member Author

The typo actually got fixed in #467 so this PR is just adding tests to the fallback constructor

@borisdevos borisdevos changed the title Typo in one-site Jordan AC Hamiltonian constructor Tests for Hamiltonian derivatives and long-range models Aug 7, 2026
@borisdevos
borisdevos requested a review from lkdvos August 7, 2026 07:36
borisdevos and others added 9 commits September 25, 2026 21:35
Versions <= 0.3.18 silently drop data on permuted contractions into
sparse block tensors under TensorKit 0.17.2 (fixed upstream in
BlockTensorKit#78 / v0.3.19), which showed up as spurious failures in
the newly-added derivative-operator regression tests near FiniteMPS
chain boundaries.
…thm loops

Instead of a separate "Long-range Hamiltonian with real scalartype" testset,
add the long-range, real-scalartype model as an extra entry in the existing
FiniteMPS/InfiniteMPS ground state model lists, so every algorithm gets
exercised against the scalartype-mismatch code path the converting
JordanMPO_AC_Hamiltonian constructor takes. Reusing the same sectortype keeps
the added wall time small (~40s vs ~2.5min for the nearest-neighbour model).

GradientGrassmann needs an explicit `tol`: without it the optimizer can
overshoot past the point where the gradient is floating-point noise, and the
CG line search's step-size formula hits a 0/0 that produces a NaN tangent,
which the SVD correctly rejects.

variance() throws a SpaceMismatch for a real, long-range InfiniteMPOHamiltonian
against a complex state (#524); the affected checks are
marked @test_broken until that's fixed upstream.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@lkdvos
lkdvos merged commit 828eddc into main Sep 26, 2026
65 of 70 checks passed
@lkdvos
lkdvos deleted the bd/ACham-typo branch September 26, 2026 02:45
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