jcmgray / quimb

A python library for quantum information and many-body calculations including tensor networks.
http://quimb.readthedocs.io
Other
467 stars 107 forks source link

How to apply gates between kets and tensors in MERA networks #75

Closed JustinS6626 closed 3 years ago

JustinS6626 commented 3 years ago

On a note related to my earlier question regarding the connection of ket tensors to a MERA network, I am wondering about applying a gate between the ket tensors and the unitaries. Should I use the gate() method, or do I need to use the insert_operator method? I am particularly wondering about how to add a CNOT gate between kets and unitaries.

jcmgray commented 3 years ago

Well there's lots of ways to do this, the most useful of which probably depends on your ultimate aim. Here's two.

Setup:

%config InlineBackend.figure_formats = ['svg']
import quimb.tensor as qtn

L = 2**4
mera = qtn.MERA.rand_invar(L)

use a Circuit

circ = qtn.Circuit(L)
circ.cnot(3, 4)
(circ.psi & mera).draw(color=['PSI0', 'CNOT'])

Screenshot from 2020-12-11 13-44-33

The circuit methods by default split low-rank gates, thus the two tensors. This might be good if you are wanting to apply a lot of QC style gates.

use a MPS / other 1D TensorNetwork

import quimb as qu

psi = qtn.MPS_computational_state('0' * L, tags='PSI0')
psi.gate_(qu.CNOT(), (3, 4), tags='CNOT')

Screenshot from 2020-12-11 13-44-59

Might be good if you want to apply more arbitrary operators, the Circuit class is really calling this under the hood. Note two differences:


These methods that work with an entire TensorNetwork1D instance are probably more convenient than low level bond-cutting and inserting tensors manually, but I can give an example of that too if you want.

JustinS6626 commented 3 years ago

Thank you very much again! That helps a lot! There is one last thing I was wondering. Since I need to control the evolution of the state closely, I am using the circuit approach, and I am wondering the optimal method to use for evolving and measuring. If I evolve and measure the state as an MPS, will I lose the effects of the MERA setup? I am sorry for the endless stream of questions, but I am very inexperienced working with quimb, and with tensor network models in general.