Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structured contraction with hyperindices does not pass output_inds along #269

Open
projekter opened this issue Nov 26, 2024 · 1 comment
Labels

Comments

@projekter
Copy link

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:

tn.contract_tags_(c_tags, which="any", **opts)

(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

@projekter projekter added the bug label Nov 26, 2024
@jcmgray
Copy link
Owner

jcmgray commented Dec 3, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants