Structured contraction with hyperindices does not pass output_inds along
What happened?
I have a larger tensor network - an MPS - which during simplification gains hyperindices. Maybe this is instead the issue and diagonal reduction should no longer return an MPS? But I guess since for every complete fixed set of hyperindices, the remaining structure is still an MPS, it could also be valid to keep this structure.
If I now contract the MPS completely using structure and properly specifying all the output indices, the call ends up in TensorNetwork.contract_cumulative, which then calls contract_tags_ without passing output_inds along. Therefore, these are inferred automatically, which of course fails due to the presence of hyperindices:
https://github.com/jcmgray/quimb/blob/6943fca875ded07bd3e2fcfd431ae0dc6098ac33/quimb/tensor/tensor_core.py#L8600
(Here, opts does not contain output_inds, as it is an explicit keyword.)
What did you expect to happen?
Contract it in the same way as if I had used all (which works) instead of ...
Minimal Complete Verifiable Example
No response
Relevant log output
<own code>
return tn.contract(..., output_inds=output_inds, **contract_opts)
quimb\tensor\tensor_core.py:8541: in contract
return self.contract_structured(tags, inplace=inplace, **opts)
quimb\tensor\tensor_1d.py:549: in contract_structured
return self.contract_cumulative(tags_seq, inplace=inplace, **opts)
quimb\tensor\tensor_core.py:8600: in contract_cumulative
tn.contract_tags_(c_tags, which="any", **opts)
quimb\tensor\tensor_core.py:8418: in contract_tags
t = tensor_contract(
functools.py:907: in wrapper
return dispatch(args[0].__class__)(*args, **kw)
quimb\tensor\tensor_core.py:281: in tensor_contract
inds_out = tuple(_gen_output_inds(concat(inds)))
Anything else we need to know?
No response
Environment
v1.9.0 on Python 3.12.7, Windows
Thanks for the issue @projekter!
I think simply passing on the output_inds would not quite be sufficient here, since the local output indices for a slice of sites will not match the overall output indices.
Treating it as not an MPS / 1D-TN anymore is probably the right thing to do, though as you say some 1D structure still remains so its not very clear cut.
One possibility would be to detect the presence of any hyper indices and turn off structured contract regardless of the TN class, assuming it to be invalid.