Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize instruction should unroll to reset + gates #1896

Closed
chriseclectic opened this issue Mar 5, 2019 · 2 comments · Fixed by #2212
Closed

Initialize instruction should unroll to reset + gates #1896

chriseclectic opened this issue Mar 5, 2019 · 2 comments · Fixed by #2212
Assignees
Milestone

Comments

@chriseclectic
Copy link
Member

What is the expected enhancement?

Make initialize a gate element that can be used directly in Aer simulators, and unrolled into reset + gates by the transpiler for devices and noisey simulations.

Current version

The (current) format for initialize as a QuantumCircuit method is circ.initialize(statevec, qr) to initialise a quantum register in a fixed state.

Proposed changes

  • Change intialize it to accept either single-qubits or a list (or register) of qubits and to be treated as an explicit reset operation followed by gates to prepare the input state.
  • On simulators and devices that support reset this would allow initialize to be placed anywhere in a circuit acting on a subset of qubits.
  • To simplify the transpiler could remove unneeded reset operations.
    • If a qubit has more than 1 reset operation in a row
    • If reset is determined to be the first operation on a given qubit (Note: but for noisy simulations one might want to leave explicit reset operations at the start of a circuit to allow for reset errors)

Circuit method

The circuit method could be initialize(state, qubits), where state is a list/ndarray that is a valid statevector, and qubits can be either a full quantum register, single-qubit, or list/tuple of qubits that match the dimension of the state vector.

Qobj serialization

A suggestion for how this could be directly serialized to qobj (if the backend supports the "initialize" instruction in its basis gates) is

{"name": "initialize", "qubits": list[int], "params": complex_vector}

Example:

Consider a 2-qubit circuit, where I want to initialize both qubits into the |1> state, the following should all be equivalent:

qr = QuantumRegister(2)

# Method 1
circ1 = QuantumCircuit(qr)
circ1.initialize([0, 0, 0, 1], qr)

# Method 2
circ2 = QuantumCircuit(qr)
circ2.initialize([0, 0, 0, 1], (qr[0], qr[1]))

# Method 3
circ3 = QuantumCircuit(qr)
circ3.initialize([0, 1], qr[0])
circ3.initialize([0, 1], qr[1])


# Implementation
circ0 = QuantumCircuit(qr)
circ0.reset(qr[0])
circ0.x(qr[0])
circ0.reset(qr[1])
circ0.x(qr[1])
@ajavadia
Copy link
Member

ajavadia commented Apr 4, 2019

This is done via #1816. But I'll keep it open because the reset part is not done yet.

@ajavadia ajavadia changed the title Initialize circuit instruction Initialize instruction should unroll to reset + gates Apr 4, 2019
@ajavadia ajavadia added this to the 0.8 milestone Apr 16, 2019
@1ucian0
Copy link
Member

1ucian0 commented Apr 25, 2019

I think #2139 is that part that was missing in this issue. Feel free to reopen otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants