Replies: 3 comments 1 reply
-
Just to make a comment here, I think there are two separate issues you are touching upon. The first is about data structures, in the sense of how we actually lay out the data as julia structs. There are many options, using tuples or custom structs, and my guess is that the performance implications are completely negligible, so I would just choose the thing that is most easy to interpret as a human. In other words, whatever is the most intuitive for each specific instance should be fine. A second point is about designing functions. Here, it is a very common pitfall to think in terms of abstract types and type hierarchies, which is I fear somewhat the direction this question is pushing towards. Very often, prematurely restricting the type signature of functions leads to bad code architectures, since you then are effectively designing code around objects. Julia often shines best by not thinking about the data structures at all, and simply ducktyping everything. This means that rather than thinking about what types of arguments the CTMRG routine should accept, it is a lot better to think about what functions the arguments should support. TLDR: instead of trying to fit everything into abstract types, I would focus more on trying to avoid specializing methods as much as possible, especially the higher level parent methods and only doing that whenever the actual layout of an object is known, writing concrete implementations for leaf methods. That way, we can decide on future additions in the future, and simply implement only the leaf methods whenever needed. |
Beta Was this translation helpful? Give feedback.
-
Also linking #113 here since that is very much related. I have no problems with having an abstract supertype, but we don't actually need a supertype to avoid code duplication, and simply write many of the functions without restrictions on the signature |
Beta Was this translation helpful? Give feedback.
-
To be able to run CTMRG on something, we just need it to be a 2D rectangular network which has an 'effective rank-4 tensor' at every site in its unit cell, i.e. something that can be contracted as if it's essentially a square rank-4 tensor. When just considering what kind of arguments each method needs to take, it doesn't seem very natural to me to define our contractible objects using an abstract supertype and then placing different sandwiches under this, or even to think of them as different kinds of tuples for every type of sandwich. Our type for 'contractible networks' could just be something that wraps a matrix, where each entry of that matrix is rank-4-like. In other words, just thinking of a network of tensor sandwiches, instead of a sandwich of 'state' networks. If we want, the contractible supertype could then just be a single concrete type on which all the relevant indexing methods are defined, with a type parameter encoding the type of local sandwich it consists of (if this is even needed). Then we could decouple our physics-inspired tensor networks ( All the leaf methods only really care about which kind of local sandwich they get, since this determines the actual contractions to be done. Again we could do this by introducing some abstract local sandwich supertype, but purely for dispatch we could just as well use tuples as long as we're clear about our conventions here. I know this is quite different from say the current boundary MPS approach where things like PEPSKit.jl/src/operators/transferpepo.jl Lines 110 to 115 in 69ae4d3 it would have probably made more sense to use a single transfer matrix type where it's local entries encode what needs to be done. |
Beta Was this translation helpful? Give feedback.
-
Currently, CTMRG only runs on
InfinitePEPS
as its state type, and with #111 also onInfinitePartitionFunction
s. However, all CTMRG contractions as well as the sparse storage structs in principle support more general objects, such as PEPS-PEPS or PEPS-PEPO-PEPS sandwiches.In order to generalize the state type that is specified by the user and passed on to
leading_boundary
we need to agree on a design. Looking at the implementation of CTMRG, it is clear that the type ofstate
needs to support indexing operations and rotations. I think there are at least two options:PEPSSandwich
andPEPOSandwich
type. Here the question would be if they should be subtyped as anInfiniteSquareNetwork
- this would however somehow create a circular hierarchy in its current state.InfiniteSquareNetworks
to represent the sandwiches, e.g.Tuple{InfintePEPS,InfinitePEPS}
, and define indexing methods such asgetindex
on them.Another thing to consider is to relax the
InfiniteSquareNetwork
interface such that it is understood as an interface which states that can be contracted using CTMRG should support. This would e.g. mean getting rid of the math and OptimKit operations.See #111 for further comments.
Beta Was this translation helpful? Give feedback.
All reactions