Repository navigation
Conversation
…mmon Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N
|
Before we look at the implementation details (I dont love the underscore helper functions), we should understand why this fix is needed and what it means for our mental model. When we discussed about hidden legs, i think we convinced ourselves that the braid chirality with the hidden leg can be chosen arbitrarily, correct? and for fermions it doesnt matter either way. the learning i think is that we need to be careful about bend_right when moving the hidden legs. and this highlights the need for extensive test with fermions where the hidden leg is odd parity, ie odd number of fermions per unit cell |
|
Yes, that's right, as far as I know. The -1 would happen only when the hidden leg has odd parity: with The tests in this PR have odd-parity hidden legs ( |
Summary
On
v2_main, finite and infinite fermionic DMRG fail withlasyten._core.SymmetryError: Need to specify bend_right!whenever Lanczos is used (eff_H.N >= 400ordiag_method='lanczos'), becauseTwoSiteH.matvecand the other effective-Hamiltonian / sweep helpers intenpy/algorithms/mps_common.pystill call non-planarlasy.permute_legsandlasy.tdot.Who hits this: TeNPy v2 users running finite or infinite fermionic DMRG (such as
FermionChainwithconserve='parity'orconserve='N'), Lanczos excited-state DMRG (orthogonal_to), or fermionicVariationalCompression(#762).While auditing fermionic signs on odd-parity finite chains (
HiddenLegTensorwith a domain hidden leg at the right boundary), a plainpermute_legs -> planar_permute_legsswap alone flippedH|theta>to-H|theta>becauselasyten's_arrange_hidden_around_public_contrbends domain hidden legs withBendRight{true}and braids them past public legs (level=-1). This PR avoids that sign flip and also preserves exact(codomain_labels, domain_labels)for both boundary and interleaved hidden legs.Changes
tenpy/algorithms/mps_common.py:lasy.permute_legsandlasy.tdotcalls acrossSweep._wrap_ortho_eff_H,OneSiteH(from_LP_W0_RP,matvec,combine_theta),TwoSiteH(matvec),ZeroSiteH(from_LP_RP,matvec), andVariationalCompression(update_local,update_new_psi) to planar operations (planar_permute_legs,planar_contraction,compose), and fix the reversed SVD domain order['p1', 'vR'] -> ['vR', 'p1']inVariationalCompression.update_local._hidden_legs_to_front_codomainand_restore_matvec_legsusing matched inverse level-separated permutations (hidden legs onlevel=-1bending left withbend_right=False, public legs onlevel=0bending right withbend_right=True), keeping non-hidden tensors on plainlasy.planar_permute_legswhile preserving exact fermionic signs and leg ordering for both contiguous and interleavedHiddenLegTensorlayouts.tests/test_infinite_dmrg.py:strict=True#762xfail ontest_free_fermions_infinite_dmrg[parity](now passes).tests/test_dmrg.py&tests/test_mps_common.py:L=12#762reproducer,L=6even/oddparity&N, Jordan-WignerSpinChaincontrol), Lanczos vsED_blockandorthogonal_toexcited states (diag_method='lanczos'), fermionicOneSiteH/TwoSiteH/ZeroSiteHmatvecvslasy.compose(H.to_tensor(), theta), all 8 contiguous/interleaved hidden-leg layouts across widths0, 1, 2, and fermionicVariationalCompression.Scope Notes
combine=True(#694),SingleSiteDMRGEngine(#698), charged-unit-cell iDMRGtest_free_fermions_infinite_dmrg[N](#763,#765), andProjectedLinearOperator.to_tensorforED_blockare separate upstream items and remain unchanged.Verification
FermionChain(L=12, J=1.0, V=0.0, mu=0.0, conserve='parity')converges to-7.2962298105587635(matching the exact cosine sum-7.296229810558755and Jordan-WignerSpinChain-7.296229810558754), andtest_free_fermions_infinite_dmrg[parity]passes (8.4e-5above-2/piatchi=16).(codomain_labels, domain_labels)and signed-theta(max residual 7.97e-16), alongside192/192finite-cut comparisons and24/24interacting Hermiticity checks (max discrepancy 1.25e-16).57 passed, 59 skipped, 1 xfailedacrosstests/test_dmrg.py,tests/test_mps_common.py,tests/test_infinite_dmrg.py), broad suite passes (331 passed), and all CI linters (ruff check,ruff format --diff,flake8 --select RST,python ./tests/linting.py) pass.Fixes #762
🤖 Generated with Claude Code
https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N