1

In qiskit the method to apply a multi control with more than 2 control qubits is:

qc.mct ( listcontrols,targetbit,listancillas, mode=mode[i])

What is the equivalent in Cirq for creating that operation to append to a cirquit?.
What i need is to decompose that operation into [RX,RY,RZ, X,H,CX], like in qiskit with transpile.

2 Answers 2

1

I think the answer is:
For creating an mct that will be executed:

q = cirq.LineQubit.range(6)
mymct = cirq.ControlledGate(sub_gate=cirq.X, num_controls=3)
opmymct=mymct(q[0],q[1],q[2],q[3])

And for decomposing it, if you are only intersted in the operation text, there are two steps. First call decompose_multi_controlled_x. The best number of free qubits(qfree) is numcontrols -2, and will output only two ccx, with much less instructions than qiskit and much faster:

d = cirq.decompose_multi_controlled_x(c,q[target],qfree)        
numinstrucs=len(d)

And then decompose each ccx (TOFFOLI) to [RX,RY,RZ, X,H,CX] gates by using qiskit transpile, wich decomposes each ccx in 15 instructions.

def mymct2(qc,c,t):
    qc.h (t )
    qc.cx (c[1] , t )
    qc.rz(-np.pi/4 , t )
    qc.cx (c[0] , t )
    qc.rz(np.pi/4 , t )
    qc.cx (c[1] , t )
    qc.rz(np.pi/4 , c[1] )
    qc.rz(-np.pi/4 , t )
    qc.cx (c[0] , t )
    qc.cx (c[0] , c[1] )
    qc.rz(np.pi/4 , c[0] )
    qc.rz(-np.pi/4 , c[1] )
    qc.cx (c[0] , c[1] )
    qc.rz(np.pi/4 , t )
    qc.h (t )

I have try it with 100 control qubits and is fast. What I did is generate the text functions (mymctN)by using the above method. This is usefful because I will execute it in my simulator "bloch computer", witch does not uses state matrixs of 2**n qubits, so it can have lot of qubits, but needs that set of instructions.

0

cirq.X(target).controlled_by(a, b, ..., z)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.