Closed jofrevalles closed 3 weeks ago
Allowing users to push tensors with different index sizes is something that scares me due to the possibility of introducing subtle and difficult to track bugs.
But I completely agree that this makes some code super cumbersome.
My idea for this is that we could allow this but through a higher-level interface such that Tenet still checks the dimensions but (and this is the key) after a wrapped region (and not on each push!
call).
Here is a prototype code:
Tenet.@unsafe_region tn begin
# here go the push!, pop!, replace!, ...
...
end
When this block of code finishes, Tenet will check if the index dimensions remain consistent and throw an error if not.
I like this idea!
Implemented in #149
Summary
A common procedure in Tensor Networks is replacing some given tensors with new ones. For example, we may have an mps and evolve it with some operator to obtain new tensors, which share the same indices but change their size. The way to do this in now
Tenet
I believe is quite cumbersome, and could be improved if we relaxed the conditions inpush!
. Currently,Tenet
checks that the new pushed tensor does match in size for all their indices. This can be a problem if we wanted to update a tensorT
that has increased in bond dimension, but we still have not computed its neighbor tensor that shares indices with. My suggestion is that we can put a keyword argument inreplace!
that relaxes the mentioned constrains inpush!
.