-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Efficient 2q state preparation methods using CZ and SQRT_ISWAP #4707
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really good. Just a few bookkeeping/cleanup items (I left on the iswap fxn; most comments apply to both).
state = qis.to_valid_state_vector(state, num_qubits=2) | ||
state = state / np.linalg.norm(state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: to_valid_state_vector
doesn't normalize for us ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it just does the appropriate type conversions for us. It also validates (up to atol) that the given state vector is normalized by np.isclose(np.sum(np.abs(state_vector) ** 2), 1)
but explicitly normalizing the state vector again improves numerical accuracy (tests fail if I remove the normalization line).
@MichaelBroughton I've addressed the comments. PTAL. |
…instead of hardcoding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Wondering if we should go through the effort of trying to make this a bit more general and letting people put arbitrary two qubit gates in ?
@MichaelBroughton Opened another issue to track the general case. I'll merge this one for now. |
…antumlib#4707) * merge_operations and merge_moments transformer primitives * Refactor to use features compatible with python3.6 * Add complexity tests for merge_operations * Add iteration info to the docstring
…lytical_decompositions/two_qubit_state_preparation.py` (quantumlib#4762) Part of quantumlib#4722 This is safe to do without going through a deprecation cycle because `optimizers/two_qubit_state_preparation.py ` was recently introduced (quantumlib#4707) in the current dev version and hasn't been released yet.
…umlib#4707) * Two qubit state preparation using sqrt(iswap) and cz * Improve numerical accuracy and additional improvements * Use circuit.final_state_vector to populate intermediate state matrix instead of hardcoding
…lytical_decompositions/two_qubit_state_preparation.py` (quantumlib#4762) Part of quantumlib#4722 This is safe to do without going through a deprecation cycle because `optimizers/two_qubit_state_preparation.py ` was recently introduced (quantumlib#4707) in the current dev version and hasn't been released yet.
…umlib#4707) * Two qubit state preparation using sqrt(iswap) and cz * Improve numerical accuracy and additional improvements * Use circuit.final_state_vector to populate intermediate state matrix instead of hardcoding
…lytical_decompositions/two_qubit_state_preparation.py` (quantumlib#4762) Part of quantumlib#4722 This is safe to do without going through a deprecation cycle because `optimizers/two_qubit_state_preparation.py ` was recently introduced (quantumlib#4707) in the current dev version and hasn't been released yet.
The PR adds methods to efficiently prepare any arbitrary 2q state from the
|00>
by applying at-most one 2q entangling gate (CZ
/sqrt_iswap
).The methods along with the new
map_operations
primitive can be used to replace thecirq.StatePreparationChannel
with the optimal operations preparing that state (under the assumption that initial state is|00>
).Fixes #4500