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

Efficient 2q state preparation methods using CZ and SQRT_ISWAP #4707

Merged
merged 8 commits into from
Dec 3, 2021

Conversation

tanujkhattar
Copy link
Collaborator

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 the cirq.StatePreparationChannel with the optimal operations preparing that state (under the assumption that initial state is |00>).

Fixes #4500

@tanujkhattar tanujkhattar requested review from cduck, vtomole and a team as code owners November 23, 2021 23:36
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Nov 23, 2021
@tanujkhattar tanujkhattar requested a review from viathor November 23, 2021 23:37
@CirqBot CirqBot added the size: M 50< lines changed <250 label Nov 23, 2021
@MichaelBroughton MichaelBroughton self-assigned this Dec 2, 2021
Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a 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).

Comment on lines +55 to +56
state = qis.to_valid_state_vector(state, num_qubits=2)
state = state / np.linalg.norm(state)
Copy link
Collaborator

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 ?

Copy link
Collaborator Author

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).

@tanujkhattar
Copy link
Collaborator Author

@MichaelBroughton I've addressed the comments. PTAL.

Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a 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 ?

@tanujkhattar
Copy link
Collaborator Author

@MichaelBroughton Opened another issue to track the general case. I'll merge this one for now.

@tanujkhattar tanujkhattar merged commit ec79736 into quantumlib:master Dec 3, 2021
thanacles pushed a commit to thanacles/Cirq that referenced this pull request Dec 11, 2021
…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
CirqBot pushed a commit that referenced this pull request Dec 23, 2021
…lytical_decompositions/two_qubit_state_preparation.py` (#4762)

Part of #4722

This is safe to do without going through a deprecation cycle because `optimizers/two_qubit_state_preparation.py ` was recently introduced (#4707) in the current dev version and hasn't been released yet.
MichaelBroughton pushed a commit to MichaelBroughton/Cirq that referenced this pull request Jan 22, 2022
…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.
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…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
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…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.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
…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
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining. size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add efficient 2Q state preparation methods for Sqrt Iswaps and CZs as Optimizers
4 participants