Tests for Hamiltonian derivatives and long-range models - #493
Merged
Merged
Conversation
lkdvos
reviewed
Jul 31, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
Member
Author
|
The typo actually got fixed in #467 so this PR is just adding tests to the fallback constructor |
lkdvos
force-pushed
the
bd/ACham-typo
branch
from
September 24, 2026 13:15
caca212 to
9098b4e
Compare
This was referenced Sep 24, 2026
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
force-pushed
the
bd/ACham-typo
branch
from
September 26, 2026 01:42
1c6d00d to
4b52e55
Compare
lkdvos
approved these changes
Sep 26, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 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 :)