So I’ve been playing around with the default.tensor device for simulating quantum circuits. Since the device is based on QUIMB, I was wondering if when simulating a circuit, is there a way to output the MPS shape (i.e. all the bond dimensions in the chain) similar QUIMB? Another way of asking this is, is there a way to return the final state as a QUIMB’s MatrixProductState instance?
Or at least can we access the maximal bond dimension of the MPS decomposition when using:
dev = qml.device('default.tensor', method='mps', max_bond_dim= None)
Hi! Thanks for your response, but that is not quite what I meant. So if you choose max_bond_dim=None, the MPS decomposition will be exact, i.e., it will take all the non-zero singular values in each SVD during the construction. What I would like to know is: in that “exact” MPS construction, where we set max_bond_dim=None, what is the maximum bond dimension, i.e. what is the maximum number of non-zero singular values obtained in the construction?
I hope this makes my question clearer. I’ve edited the tittle a little bit to (hopefully) make it clearer.
I may be incorrect, but I’m pretty sure if given some matrix M and it was encoded using PennyLane, it is done by initializing some np.ndarray and then it is flattened.
Would this not remove the ability to be able to determine the max bond dimension directly from the array?
Basically, what I’m saying is that in QUIMB, when defining an MPS as a MatrixProductState instance, it allows you to extract each of the tensors composing the MPS “chain”. The shape of each tensor is of the form (i, j, k), where i and k are bond dimensions and j is the physical dimension (j=2 for qubit states).
You can always obtain the statevector as a dense array with the method to_dense() which will contract the tensor network into a flattened array of 2^num_qubits elements.
Since the backend of default.tensor is QUIMB, I’m wondering if I can do something similar here.
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.
Thanks for jumping in and offering to help @Classy ! Your discussion in the first few posts in this thread was useful to me to understand the issue/question.