Repository navigation
Conversation
`_instantiate_operators` ran all of the work of the `MPOHamiltonian` constructors inside `map(collect(local_operators)) do term ... end`. Below that `map` call, type inference applies its recursion limit to every nested `map` over a vector whose element type is not concrete, such as `map(dual, S.spaces)` in `dual(::SumSpace)`. The limited results are not cached, so each function between the two `map` calls is inferred again at every call site (JuliaLang/julia#64862). A comprehension gives the same result without a `map` frame at the root. First call of `InfiniteMPOHamiltonian([P, P], (1, 2) => h, (2, 3) => h)` from that issue: | Julia | before | after | |---------------|------------------|------------------| | 1.10.13 | 10.7 s, 4.5 GiB | 9.4 s, 3.5 GiB | | 1.13.3 | 36.0 s, 16.7 GiB | 16.8 s, 7.6 GiB | | 1.14.0-alpha2 | 29.5 s, 16.4 GiB | 14.7 s, 7.9 GiB | Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Put inference barriers around the calls in `_instantiate_operators` that receive the untyped representatives, and reorder the inverse `swap!` contraction so that `τ'` is not the first `@plansor` tensor. That ordering threw `UndefVarError: τ` (QuantumKitHub/TensorKit.jl#622), and since it was an undefined global it also made the whole method infer abstractly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Group the representatives in `_instantiate_operators` by operator type, so that each group is a concretely typed vector. This removes the abstract inference that the inference barriers worked around, so those barriers are removed. Proportional operators of different types (e.g. a real and a complex copy of the same operator) no longer share a decomposition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # src/operators/mpohamiltonian.jl
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
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.
This builds on #556 and contains its commits, so it should be merged after #556. Only the commit "Store the representatives in concretely typed vectors" is new here.
#556 puts inference barriers around the calls that use the
representativesof_instantiate_operators. This PR fixes the cause instead: the representatives are grouped by operator type, so each group is stored in a concretely typed vector, and the barriers are removed.FiniteMPO(O)already infers concretely, soBase.promote_op(FiniteMPO, typeof(O))gives the element type of each group.Behaviour change: proportional operators are now only merged when they have the same type. For example, a real and a complex copy of the same operator no longer share a decomposition, and so no longer share virtual channels. Both are still built correctly; the bond dimension can just be larger in that case. No existing test covers it. This is why the change is in a separate PR.
On Julia 1.13.3, building the SU(2) Heisenberg
InfiniteMPOHamiltonianin a fresh process, from a single A/B run:swap!)Both remove the same abstract inference. The remaining difference of about a second is within what one run can resolve. Keeping only the outer barrier on
instantiate_operatorgave 15.8 s, so that barrier is not needed.Locally, the
mpo/finite,hamiltonian,operatorsandalgorithms/changebondstest files pass.🤖 Generated with Claude Code