Extract MPS shape in default.tensor

Hi @loruma

My colleague Pietropaolo found a way to obtain the information you need!

A way to access the underlying quimb instance of the circuit is by using the private class attribute _quimb_circuit:

import pennylane as qml

dev = qml.device("default.tensor", wires=2)

dev._quimb_circuit

The output is:

<Circuit(n=2, num_gates=0, gate_opts={'contract': 'auto-mps', 'propagate_tags': False, 'max_bond': None, 'cutoff': None, 'info': {}})>

The _quimb_circuit attribute allows manipulating the quimb instance that the device creates under the hood.

To get the MPS in a dense form we can do the following:

dev._quimb_circuit.psi.to_dense()

The output is:

array([[1.+0.j],
       [0.+0.j],
       [0.+0.j],
       [0.+0.j]])

Note: The _quimb_circuit attribute is private because it’s not compatible with PennyLane’s new device API, so things might break for certain workflows.

Let us know if this works for you or if you have trouble using it.

I hope this helps!