Remove MPSKitModels dependency#394
Conversation
- Replace all MPSKitModels operator building blocks with TensorKitTensors counterparts (SpinOperators, BosonOperators, HubbardOperators, TJOperators) - Convert model constructors from MPSKitModels extensions to PEPSKit-native functions - Remove AbstractLattice supertype; InfiniteSquare is now a plain struct - Update tests, examples, docs, and notebooks to use TensorKitTensors imports - Remove MPSKitModels from all Project.toml files Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
lkdvos
left a comment
There was a problem hiding this comment.
Definitely in favor of using TensorKitTensors for the operators, but I'm not entirely sure if we gain a lot by decoupling the actual models. The main thing I worry about is that there are now two functions for each model, and you have to remember that PEPSKit.hubbard_model !== MPSKitModels.hubbard_model.
We should however probably discuss this in a bit more detail together, since I agree that the MPSKitModels package is a bit awkward. I would be happy to include most of that functionality in MPSKit, for example, since I feel like it does not actually warrant a separate package, but in that case probably we should move out the lattice stuff in a different package (ie. TiledArrays/LatticeArrays or something similar).
This is easy 😂 Actually for newcomers I don't think they expect MPSKitModels to provide 2D Hamiltonians? |
|
Well, the point is that if you accidentally do something like |
Before TensorKitTensors exists, I needed to import MPSKitModels to access pre-defined operators in order to define custom Hamiltonians. This was already causing a name clash on
Dependence on MPSKit is quite reasonable, since it should be common knowledge that PEPS can be contracted with boundary MPS methods. But getting PEPSKit Hamiltonians from MPSKitModels has always weirded me out. After rewriting the Hamiltonians with TensorKitTensors, what remains that still depends on MPSKitModels is just the AbstractLattice stuff. Since we are currently supporting square lattice only, I think it's not worth it to keep depending on another package that is not designed to work with PEPS. Although this will be a breaking change, the function signatures remain untouched, so the difference is not that dramatic. |
|
Using TensorKitTensors over MPSKitModels for the operators is a strict improvement, no doubt about that. Regarding the models, it is conceptutally a bit strange to rely on MPSKitModels just to overload the model methods. However, I think it's almost equally strange to introduce new methods with exactly the same name and signature, and even literally copy over the docstrings from MPSKitModels. Getting PEPSKit Hamiltonians from MPSKitModels is indeed weird, but given that the MPSKitModels ones already exist there's also no real reason not to reuse them. At the end of the day, the main issue is that using operators from MPSKitModels is not a good idea. This is resolved here. The fact that the model names originate from MPSKitModels is not really visible from the outside, since we re-export all of the model methods from PEPSKit. The naming clashes that arise from So I would be in favor of keeping the MPSKitModels dependency. Even if it's just not to copy over the model docstrings, this is already worth it to me. Then we just bury the actual dependency so we don't give anyone a reason to ever import MPSKitModels themselves. This includes not mentioning the model methods come from MPSKitModels in the documentation, which is already done in this PR. At that point, are there still any real downsides to having MPSKitModels as a dependency? |
| We will construct the Bose-Hubbard model Hamiltonian through the | ||
| [`bose_hubbard_model`](https://quantumkithub.github.io/MPSKitModels.jl/dev/man/models/#MPSKitModels.bose_hubbard_model), | ||
| function from MPSKitModels as reexported by PEPSKit. We'll simulate the model in its | ||
| [`bose_hubbard_model`](@ref) defined in PEPSKit. We'll simulate the model in its |
There was a problem hiding this comment.
For example, here we could keep the updated text to not refer to MPSKitModels, but just change the (@ref) to (@extref MPSKitModels.bose_hubbard). This is not visible to readers, but allows to reuse at least the docstring.
The point is that we don't need to worry about the two packages becoming out of sync. For example, if we want to add next-nearest neighbor options (like So it looks like duplicating things right now, but is more future-proof in my opinion. |
|
Moreover, the model docstrings in MPSKitModels say they are "MPO for the hamiltonian". So they clearly do not apply to PEPSKit, and I have made the adjustments. |
|
For the environment initialization test with partition function of Ising model, I suggest we duplicate the Z2Irrep version of |
I didn't notice this, that is unfortunate. This does kind of defeat the point of my earlier comment. If there's nothing that can be reused, forcing reuse is indeed not a good idea.
This I really don't like, to be honest. Even though it's not very long, that would mean defining exactly the same tensor in three different packages within our own organization. If we keep copying it over from MPSKitModels because we don't want to depend on it, clearly something is wrong and it shouldn't have been defined there in the first place. But then at least we should move it to TensorKitTensors, and import it from there. |
|
Then for now we depend on MPSKitModels only for the tests.
This sounds good. @VictorVanthilt How do you feel about also moving some "widely used" classical 2D partition function tensors from TNRKit to a new submodule (maybe naming it |
This PR removes MPSKitModels dependency. The main purpose is to use pre-defined operators from TensorKitTensors.
AbstractLatticeis lost. But I think this will eventually be replaced by TiledArrays?Some issues that are addressed:
sublattice = true(S_xx, S_yy with U1Irrep symmetry MPSKitModels.jl#57). With TensorKitTensors, an error will be correctly raised.pwave_superconductoris actually a p-ip (instead of p+ip) wave Hamiltonian. I wonder if we want to change the convention and update the benchmark energy in the test.