TransWikia.com

Conjugate transpose of a U-gate

Quantum Computing Asked by Anders Julton on January 12, 2021

I want to be able to create the circuit depicted below, but running the code below results in an empty circuit when viewing the job afterwards.

enter image description here

backend = provider.backends.ibmq_armonk


qreg_q = QuantumRegister(1, 'q')
creg_c = ClassicalRegister(1, 'c')
circuit = QuantumCircuit(qreg_q, creg_c)

circuit.u(pi/2, pi/2, pi/2, qreg_q[0])
circuit.x(qreg_q[0])
circuit.y(qreg_q[0])
circuit.x(qreg_q[0])
circuit.y(qreg_q[0])
circuit.u(pi/2, pi/2, pi/2, qreg_q[0]).inverse()

circuit.measure(qreg_q[0], creg_c[0])


qobj = assemble(transpile(circuit, backend=backend), backend=backend)
job = backend.run(qobj)
retrieved_job = backend.retrieve_job(job.job_id())

2 Answers

Indeed, your circuit can be reduced to an identity circuit as @KAJ226 nicely explains here. The transpilation process notices that and reduces your gates to idle during circuit depth optimization:

qreg_q = QuantumRegister(1, 'q')
creg_c = ClassicalRegister(1, 'c')

circuit = QuantumCircuit(qreg_q, creg_c)
circuit.u(pi/2, pi/2, pi/2, qreg_q[0])
circuit.x(qreg_q[0])
circuit.y(qreg_q[0])
circuit.x(qreg_q[0])
circuit.y(qreg_q[0])
circuit.u(pi/2, pi/2, pi/2, qreg_q[0]).inverse()

circuit.measure(qreg_q[0], creg_c[0])

transpile(circuit, backend=backend).draw('mpl')

enter image description here

You can avoid the optimization by reducing the optimization level to $0$:

transpile(circuit, backend=backend, optimization_level=0).draw('mpl')

enter image description here

In your example, you need to modify the transpile call like this:

qobj = assemble(transpile(circuit, backend=backend, optimization_level=0), backend=backend)

Correct answer by luciano on January 12, 2021

Just want to add a small additional detail here that might be useful for future encounter.

The reason why you see the circuit with only measurement after the transpilation process is because $(XY)^dagger = Y^dagger X^dagger = -XY$. Since

$$ XY = begin{pmatrix} 0 & 1 1 & 0 end{pmatrix}begin{pmatrix} 0 & -i i & 0 end{pmatrix} = begin{pmatrix} -i & 0 0 & i end{pmatrix}$$ and $$ (XY)^dagger = Y^dagger X^dagger = begin{pmatrix} 0 & -i i & 0 end{pmatrix} begin{pmatrix} 0 & 1 1 & 0 end{pmatrix} = begin{pmatrix} i & 0 0 & -i end{pmatrix}$$

Now note that $(XY)(XY)^dagger =I $ because of definition of Unitary, and so $ XYXY = -XY(XY)^dagger = -I $ but in quantum computing, global phase doesn't matter, so $-I = I$... since there is no experiment you can do to distinguish $|0rangle$ from $-|0rangle$.

Now, looking at your circuit, we have: $$UXYXYU^dagger = UXY[-(XY)^dagger] U^dagger = -[UXY(XY)^dagger U^dagger] = -[U I U^dagger] = -[UU^dagger] = -I equiv I $$
During the transpilation step, it recognizes this and made the reduction to save the possible number of quantum operations needed...hence the reason why your circuit only consists of the measurement procedure.

Answered by KAJ226 on January 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP