Hello, I am trying to implement a simple and naive grover algorithm using the following code:
Code
Gates declaration
X = catalog[‘x’].build_processor()
H = catalog[‘h’].build_processor()
cnot = catalog[‘heralded cnot’].build_processor()
toffoli = catalog[‘toffoli’].build_processor()
Our qubits in the dual rail encoding
q1, q2, q3 = [0,1], [2,3], [4,5]
Initialisation
p = pcvl.Processor(“SLOS”,6)
p.add(q3, X)
p.add(q1, H)
p.add(q2, H)
p.add(q3, H)
Naive oracle
p.add(q1, X)
p.add(q1+q2+q3, toffoli)
p.add(q1, X)
Amplification
p.add(q1, H)
p.add(q2, H)
p.add(q1, X)
p.add(q2, X)
p.add(q2, H)
p.add(q1+q2, cnot)
p.add(q2, H)
p.add(q1, X)
p.add(q2, X)
p.add(q1, H)
p.add(q2, H)
printing the circuit
pcvl.pdisplay(p,recursive=False)
Questions
When commenting either the toffoli OR the CNOT, the circuit gets printed.
But when I let both, I get :
AssertionError: Post-selection conditions cannot compose with modes [0, 1, 2, 3]
From what I am understanding, we cannot post select because when we post select on thoses modes we can guarantee we have qubits at the end but we cannot guarantee in the middle of the two that we effectively had qubits (~that the first CNOT worked). Is this Right ?
If this is right, why can we use multiple (as in strictly more than one) CNOT in
Detailed walkthrough — perceval v0.13 documentation