TransWikia.com

How to not optimize the quantum gates in a qiskit circuit when running it in the real device?

Quantum Computing Asked on March 1, 2021

I have been trying to run two circuits in the ibmq_london device, the one resulting of applying one X gate on qubit $0$ and the one that applies two X gates. I know that applying two X gates is the same as doing nothing because of its properties, but I am interested in the study of noise so I really want Qiskit to apply both gates. I have tried to place a barrier between both X gates but it does not seem to be working because I obtain the following results:

X circuit

enter image description here

XX circuit

enter image description here

I have tried to write the following code:

job_device = execute(qc, device,shots=8192,basis_gates=None,optimization_level=0)

for the execution, but it does not seem to be working as due to the effect of noise I will expect a lower value for the XX circuit (two gates applied), even taking into account the thermal relaxation.

One Answer

Optimization level 0 does not perform 1 qubit gate optimization and it will send 2 X gates (well 2 U3 gates after it unrolls to the basis set). You can see the passes optimization level 0 runs here: https://github.com/Qiskit/qiskit-terra/blob/master/qiskit/transpiler/preset_passmanagers/level0.py It will only map the circuit to the device and unroll the gates to the basis set. You can see what the compiled circuit which will be sent to the device looks like with:

print(transpile(qc, device, optimization_level=0))

Which should show you 2 U3(pi,0,pi) gates next to each other. For example, when I ran it locally it shows:

>>> print(transpile(qc, backend, optimization_level=0))
               ┌─────────────┐┌─────────────┐ ░ ┌─┐      
      q_0 -> 0 ┤ U3(pi,0,pi) ├┤ U3(pi,0,pi) ├─░─┤M├──────
               └─────────────┘└─────────────┘ ░ └╥┘┌─┐   
      q_1 -> 1 ───────────────────────────────░──╫─┤M├───
                                              ░  ║ └╥┘┌─┐
      q_2 -> 2 ───────────────────────────────░──╫──╫─┤M├
                                              ░  ║  ║ └╥┘
ancilla_0 -> 3 ──────────────────────────────────╫──╫──╫─
                                                 ║  ║  ║ 
ancilla_1 -> 4 ──────────────────────────────────╫──╫──╫─
                                                 ║  ║  ║ 
       meas_0: ══════════════════════════════════╩══╬══╬═
                                                    ║  ║ 
       meas_1: ═════════════════════════════════════╩══╬═
                                                       ║ 
       meas_2: ════════════════════════════════════════╩═

Answered by Matthew Treinish on March 1, 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