-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Adding depth-5n synthesis algorithm for -CZ-CX- circuits #9932
Conversation
Adding the synthesis algorithm that jointly synthesize a CNOT circuit and CZ circuit in depth 5n by inserting P gates to the CNOT network. Reference: D. Maslove and W. Yang, "CNOT circuits need little help to implement arbitrary Hadamard-free Clifford transformations they generate," 2022. https://arxiv.org/abs/2210.16195
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 5522429506
💛 - Coveralls |
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.
Thank you very much for your contributions @Willers-Yang !
In order to prepare your PR to get merged into Qiskit there are some things that should be done first:
-
Could you please sign the CLA agreement?
-
Could you please fix the format errors? (black and lint), see: https://github.com/Qiskit/qiskit-terra/blob/main/CONTRIBUTING.md#style-and-lint
-
Could you please add proper docstrings to the functions? see the following example:
https://github.com/Qiskit/qiskit-terra/blob/5672c70649b4f83a6c7146c68a6a543d4a3908fd/qiskit/synthesis/linear_phase/cz_depth_lnn.py#L136
In addition, could you add a test that generates a random clifford element, synthesizes it with using your cx_cz_synth_func
, asserting that you get back the same clifford, with LNN connectivity and depth 7n+2, to:
https://github.com/Qiskit/qiskit-terra/blob/main/test/python/synthesis/test_clifford_decompose_layers.py
It also makes sense to update the code in this function, to synthesize a clifford circuit in depth 7n+2 (instead of the current code with depth 9n+4) as part of this PR.
https://github.com/Qiskit/qiskit-terra/blob/5672c70649b4f83a6c7146c68a6a543d4a3908fd/qiskit/synthesis/clifford/clifford_decompose_layers.py#L399
@Willers-Yang - thank you for addressing my comments, and fixing the style errors. First, you should add the new function Second, could you please add release notes? I would recommend to look at previous PRs in order to keep the exact format, otherwise, CI checks will fail with docs errors, for example #9450. |
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.
Thank you very much for your important contribution to Qiskit!
I have a few minor comments.
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.
Thank you very much for your important contribution to Qiskit!
I have a few minor comments.
accompanied by a CZ circuit for linear nearest neighbor (LNN) connectivity in | ||
2-qubit depth of 5n using CX and phase gates (S, Sdg or Z). The synthesis algorithm | ||
is based on the paper of Maslov and Yang (https://arxiv.org/abs/2210.16195). | ||
For LNN connectivity in 2-qubit depth of 7n+2 (which is still not optimal), |
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.
Minor: I would remove the comments on non-optimality and the follow-up PR.
--- | ||
features: | ||
- | | ||
Add a new synthesis algorithm `.synth_cx_cz_depth_line_my` of a CX circuit |
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.
Could we add an example here? Including both how we should run the code and what the output would look like?
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.
@Willers-Yang, many thanks for this contribution! The PR looks very good. My main comment is to update the release notes with an example on how to use the new code and what its output would look like.
Thank you for leaving some comments! I have addressed them in the new commit. Please let me know if the example added to the release notes is okay! |
Summary
This PR adds the linear-nearest neighbor synthesis algorithm that jointly synthesizes a CNOT circuit accompanied by a CZ circuit in depth 5n phase gate insertions to the CNOT network. The aim is to reduce the Clifford decomposition circuit depth from 9n to 7n+O(1)
The algorithm, synth_cx_cz_line_my, takes as input two matrices mat_x, mat_z representing the corresponding -CX- and -CZ- circuits, and returns a depth-5n QuantumCircuit object with linear-nearest-neighbour connectivity.
Reference: D. Maslov and W. Yang, "CNOT circuits need little help to implement arbitrary Hadamard-free Clifford transformations they generate," 2022, https://arxiv.org/abs/2210.16195
Details and comments
This PR adds on to #9220 and #9036 to allow us to decompose a Clifford circuit in depth 7n+2 over LNN connectivity.
Will be followed by a future PR implementing further local optimizations to reduce the Clifford circuit depth to 7n-4 over LNN.