Skip to content

perf: longer-range AC2_Hamiltonian improvements - #505

Merged
lkdvos merged 3 commits into
mainfrom
contraction-order
Aug 6, 2026
Merged

perf: longer-range AC2_Hamiltonian improvements#505
lkdvos merged 3 commits into
mainfrom
contraction-order

Conversation

@lkdvos

@lkdvos lkdvos commented Aug 5, 2026

Copy link
Copy Markdown
Member

This PR addresses some of the performance issues that got brought up recently for MPOs beyond nearest-neighbour.

  1. BlockTensorMap slicing was repeated multiple times, which could just be done once upfront (minor overhead)
  2. the "CA" term had a contraction order mistake, leading to an intermediate object of size D^2 V d^2 before the final D^2 d^4 instead of the (better) intermediate d^4 V.
  3. the "AA" term was contracting terms that did not contribute anything.

A concrete example of this last machinery is found by considering a longer-range term that ends on the right physicalspace. This has support in the first A block, but then connects to the the second B block (and is already accounted for in the "AB" term). Nevertheless, this was still contributing a channel to the "AA" terms, needlessly increasing the MPO bond dimension on the most expensive contraction.

I already had some machinery in place for detecting something similar, but was missing quite a few cases still, which mostly bites for hamiltonians that have a variety of terms that span ranges >2.

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../algorithms/derivatives/hamiltonian_derivatives.jl 75.00% 10 Missing ⚠️
Files with missing lines Coverage Δ
.../algorithms/derivatives/hamiltonian_derivatives.jl 89.51% <75.00%> (-3.91%) ⬇️

... and 2 files with indirect coverage changes

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

@lkdvos
lkdvos marked this pull request as ready for review August 6, 2026 01:17
@lkdvos
lkdvos merged commit dada988 into main Aug 6, 2026
34 of 37 checks passed
@lkdvos
lkdvos deleted the contraction-order branch August 6, 2026 11:07
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