quimb icon indicating copy to clipboard operation
quimb copied to clipboard

Gating with hyperindices fails

Open projekter opened this issue 6 months ago • 1 comments

What happened?

I have tensor networks with hyperindices; now I use gate_inds_with_tn to put them together. If one of the indices that are supposed to be gated together happens to be such a hyperindex (in both networks), this will run into a problem: https://github.com/jcmgray/quimb/blob/948090035b43025a4e0af6e595c173aed5d69a5c/quimb/tensor/tensor_core.py#L6198-L6200 Here, the indices are first renamed appropriately, then the tensor network is merged together. During merging, Quimb will automatically try to mangle inner indices: https://github.com/jcmgray/quimb/blob/948090035b43025a4e0af6e595c173aed5d69a5c/quimb/tensor/tensor_core.py#L4335-L4340 However, given that now the gated indices are hyperindices, they will be seen as "inner" and therefore mangled - leading to a disconnected network in the end. Basically, to avoid this, it would have to be necessary to pass output_inds along to a couple of routines along the way.

Here's a short sequence of images illustrating the problem (where I contracted lots of stuff away to figure out what's going on): Network Image

Operator Image

Gating network's "k0" with operator's "b0" and network's "k1" with operator's "b1" Image

What did you expect to happen?

A single connected tensor network

Further information

Edit: I also tried force-overwriting _inner_inds and _outer_inds before gating. Unfortunately, when the reindexing is done, _link_inds and _unlink_inds is called, which are not aware of hyperindices, reverting the change.

Environment

v1.11.1

projekter avatar Jul 18 '25 12:07 projekter

Hi @projekter, thanks for the issue. Yes this might be similar to #32, i.e. on my list of to-dos for a long time but no-one had run into it until now. Perhaps you could put together a minimum working example that I can test on?

jcmgray avatar Jul 30 '25 21:07 jcmgray