Hi,
I’m trying to use the heralded CNOT in a circuit, but the simulation takes too much memory. Here is a code that can reproduce the problem:
import perceval as pcvl
import numpy as np
from perceval.components import BS, PS
from perceval.components import catalog
import timeit
p = pcvl.Processor("SLOS",6)
cnot = catalog['heralded cnot'].as_processor().build()
p.add([0,1,2,3],cnot)
p.add(2,BS.H())
p.add(2,BS.Rx(2*0.00523828))
p.add(2,BS.H())
p.add([0,1,2,3],cnot)
p.add([0,1,4,5],cnot)
p.add(4,BS.H())
p.add(4,BS.Rx(2*0.00523828))
p.add(4,BS.H())
p.add([0,1,4,5],not)
start = timeit.default_timer()
p.with_input(pcvl.BasicState([1, 1, 1, 1, 1, 1]))
output_distribution=p.probs()["results"]
pcvl.pdisplay(output_distribution, max_v=10)
stop = timeit.default_timer()
print('Time: ', stop - start)
For two herald CNOT, it takes 0.784 s to finish the simulation. For 3 CNOT, 306.68 s, and in the case of 4 CNOT, it takes too much memory. In this case, what is the problem? Is there a better way of working with CNOT in Perceval? or maybe there are some mistakes in how I’m using it?
Thanks for the help!