Skip to content

too many subscripts in einsum #80

@punkdit

Description

@punkdit

Here is the bottom of my stack trace:

  File "/home/simon/site-packages/opt_einsum/contract.py", line 731, in __call__
    return self._contract(ops, out, backend, evaluate_constants=evaluate_constants)
  File "/home/simon/site-packages/opt_einsum/contract.py", line 667, in _contract
    **self.einsum_kwargs)
  File "/home/simon/site-packages/opt_einsum/contract.py", line 563, in _core_contract
    new_view = _einsum(einsum_str, *tmp_operands, backend=backend, **einsum_kwargs)
  File "/home/simon/site-packages/opt_einsum/sharing.py", line 161, in cached_einsum
    return einsum(*args, **kwargs)
  File "/home/simon/site-packages/opt_einsum/contract.py", line 360, in _einsum
    return fn(einsum_str, *operands, **kwargs)
ValueError: Internal error while evaluating `ContractExpression`. Note that few checks are performed - the number and rank of the array arguments must match the original expression. The internal error was: '('too many subscripts in einsum',)'

It looks like numpy-einsum is barfing here:

def iterlabels(labelstr, output_labels, ndim_output):
    """
     * Set up the labels for the iterator (output + combined labels).
     * Can just share the output_labels memory, because iter_labels
     * is output_labels with some more labels appended.
    """
    iter_labels = output_labels[:]
    ndim_iter = ndim_output
    for label in range(labelstr.min_label, labelstr.max_label+1):
        if labelstr.counts.get(label, 0) > 0 and label not in output_labels:
            if ndim_iter > 128:
                raise ValueError('too many subscripts in einsum')
            iter_labels.append(label)
            ndim_iter += 1
    # may have 0 in iter_labels
    return iter_labels

This is strange because I get the path_info from contract_path and it tells me
that largest_intermediate is of size 134217728, which seems doable.

I'm wondering how einsum ended up with more that 128 labels (i'm assuming these are tensor indices?) Perhaps there are a bunch of trivial indices being summed over...

Any suggestions ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions