Skip to content

Transpiler removes resets at beginning of circuits unless level=0 #6943

@nonhermitian

Description

@nonhermitian

Information

  • Qiskit Terra version: latest
  • Python version:
  • Operating system:

What is the current behavior?

qc = QuantumCircuit(5, 4)
qc.reset(range(5))
qc.x(4)
qc.h(range(5))
qc.cx(range(4), 4)
qc.draw()
qc.h(range(4))
qc.barrier()
qc.measure(range(4), range(4))
qc.draw('mpl')

image

becomes:

backend = FakeCasablanca()
trans_qc = transpile(qc, backend)
trans_qc.draw('mpl')

image

Steps to reproduce the problem

Run above at optimization levels 1->3.

What is the expected behavior?

If the user explicitly puts resets at the beginning of a circuit they should remain there. This is important as the unconditional reset done by default on IBM Quantum systems is not perfect, leading to state prep errors. Adding a reset at the beginning of a circuit greatly suppresses these errors and is needed to get high-fidelity results.

Suggested solutions

Do not remove resets at the beginning of circuits. i.e. do not run this RemoveResetInZeroState

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions