qiboteam / qibo-core

Core qibo elements
https://qibo.science
1 stars 0 forks source link

Einsum dance #4

Open alecandido opened 6 months ago

alecandido commented 6 months ago

While reviewing the potential content of qibo-core, I found the following interesting pieces of code:

https://github.com/qiboteam/qibo-core/blob/13a1294460ce4a61f9938b4de649224f615b65bf/src/qibo_core/config.py#L23-L24 https://github.com/qiboteam/qibo-core/blob/13a1294460ce4a61f9938b4de649224f615b65bf/src/qibo_core/backends/einsum_utils.py#L11-L12 https://github.com/qiboteam/qibo-core/blob/13a1294460ce4a61f9938b4de649224f615b65bf/src/qibo_core/backends/einsum_utils.py#L50-L51 ...

But since NumPy 1.10.0 (~2015) an alternative syntax is supported:

einsum also provides an alternative way to provide the subscripts and operands as einsum(op0, sublist0, op1, sublist1, ..., [sublistout]). If the output shape is not provided in this format einsum will be calculated in implicit mode, otherwise it will be performed explicitly. The examples below have corresponding einsum calls with the two parameter methods.

https://numpy.org/doc/stable/reference/generated/numpy.einsum.html

It could be worth to spend a little of effort to implement it, and lift this limitation to 52 qubits (though for pure state vector is pretty much irrelevant...).

alecandido commented 4 months ago

Relevant, but not part of qibo-core any longer, we should transfer the issue...