Repository navigation
Conversation
#557 made the Hamiltonian constructors destructure every term as `inds => O`, so terms of other types, such as MPSKitModels' `LocalOperator`, were no longer handed to `instantiate_operator(lattice, term)`. Terms now first go through the internal `_local_term`, which turns a pair into linear indices and the operator, and hands any other term to `instantiate_operator`, dropping the identity padding again. `instantiate_operator(lattice, ::Pair)` keeps returning the padded local MPO, as in v0.14.1. Assisted-by: Claude Code
- share the channel graph and unit space between the finite and infinite case - check the operator types once, through `_mpo_tensortype` - find the bucket of an operator through its element type - shorten the comments to the non-obvious parts Assisted-by: Claude Code
Member
Author
|
@hz-xiaxz I would love to request a review from you for this one as well. The idea is to make the MPSKitModels PR an optional performance improvement, such that we can release a non-breaking version here, separately from that issue (which I think we should also do in any case, but that can thus be handled separately). |
Open
This branch has not been deployed
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.
Follow-up to #557, which broke MPSKitModels: the Hamiltonian constructors started destructuring every term as
inds => O, so terms of other types were no longer handed toinstantiate_operator(lattice, term). MPSKitModels overloads that function for itsLocalOperator, so@mpohamand every model built on it threw aMethodError(reported in #557 (comment)).This restores the old behaviour without giving up the compile-time improvements:
_local_term(lattice, term) -> indices => operator.instantiate_operator(lattice, term), and the identities padding the sites in between are dropped again. The constructors add them back later.instantiate_operator(lattice, inds => O)returns the paddedsites => local_mpoagain, exactly as in v0.14.1. It is now built from_local_termand the internal_local_mpo, which is the former three-argument method that Store Hamiltonian-term representatives in concretely typed vectors #557 had added._local_termthrough an inference barrier. Otherwise inference walks the generic method into the tensor code with abstract types, which doubles allocations on the first construction.Checks:
instantiate_operatoris identical to that of main before Store Hamiltonian-term representatives in concretely typed vectors #557 (ea2d2d8) forInt, tuple, unsorted, 3-site,CartesianIndex,FiniteMPOand repeated-index terms, as well as for thestatemethod.heisenberg_XXX()(also with SU(2) symmetry),heisenberg_XXX(FiniteChain(4)),transverse_field_ising(FiniteChain(6))andhubbard_model(InfiniteChain(2)). The bond dimensions are the same as before Store Hamiltonian-term representatives in concretely typed vectors #557.hamiltonianandalgorithms/correlatorstests pass locally.With this, QuantumKitHub/MPSKitModels.jl#90 is no longer required for compatibility.
Assisted by Claude Code