Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
4.91k stars 2.31k forks source link

shouldn't single-qubit initialization decomposition result in single-qubit instructions? #5134

Closed 1ucian0 closed 3 years ago

1ucian0 commented 3 years ago

Not sure if an issue, so tagging as question for now. If I'm saying nonsense, an explanation would be enough to close this issue (even if I don't understand it).

When creating an initializer with single-qubit states, I would expect that the decomposition turns into single qubits gates/instructions. In this case1 I want to initialize two qubits in |1>:

from qiskit.extensions.quantum_initializer.initializer import Initialize
initialize = Initialize([ 0, 0, 0, 1])

The result of decomposing it, I think, should be something along these lines:

initialize.definition.draw()
          ┌───┐
q_0: ─|0>─┤ X ├
          ├───┤
q_1: ─|0>─┤ X ├
          └───┘

However, it results in a circuit with CNOTs:

from qiskit import transpile
transpile(initialize.definition, basis_gates=['u3', 'cx', 'reset'], optimization_level=0).draw()
          ┌──────────────┐┌───┐┌───────────────┐┌───┐
q_0: ─|0>─┤ U3(pi/2,0,0) ├┤ X ├┤ U3(-pi/2,0,0) ├┤ X ├
          └┬────────────┬┘└─┬─┘└───────────────┘└─┬─┘
q_1: ─|0>──┤ U3(pi,0,0) ├───■─────────────────────■──
           └────────────┘                            

I understand that synthesis is something hard you want to keep general and probably we dont want to handle too many "special cases" (or do we?). To this end, would it help to support something likeInitialize('11') (a la Statevector.from_label)?

In summary,

Footnotes: 1 This issue is inspired by a question in stack exchange 2 Supporting Statevector as Initializeparameter seems intuitive to me in any case. Currently an unexpected .data needs to be added Initialize(Statevector.from_label('11').data)

1ucian0 commented 3 years ago

From some in-webex discussions, it seem the way to go will be Initialize('11'). Implemented in #5229