qiskit-aer
qiskit-aer copied to clipboard
Setting the initial state to a basis state
What is the expected behavior?
We have a use case where the initial state is a basis state. Right now we have two options:
- Using the
initialize
instruction. This involves creating a 2^n state vector outside of the simulator and transmitting it to the simulator. - Inserting X gates at the beginning of the circuit. This has the cost of increasing the circuit depth, affecting run time.
I suggest to do at least one of the following:
- Allow
initialize
to receive the vector in the form of a dictionary that maps basis states to amplitudes, where zero amplitudes do not have to be present. - Implement an optimization in the simulator that simulates a sequences of Pauli gates in one matrix loop.
Option 2 above is related to #715.
The rest of this issue is for Option 1. Issue #715 is for Option 2. We will probably need to write a function ket2vec
in utils.hpp
, similar to the existing vec2ket
. It will be nice if Terra eventually supports initialize
that accepts a ket; in the meantime we can create our own instruction and add it to the set of basis gates when transpiling. Alternatively, it may be possible to hack parameters and data types of initialize
.
Hello, is this issue still open? I am new to the project, happy to work on this with some guidance :)
Let me close this issue. Please create a new issue if this is required to users.