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

Adding depth-5n synthesis algorithm for -CZ-CX- circuits #9932

Merged
merged 16 commits into from
Jul 12, 2023

Conversation

Willers-Yang
Copy link
Contributor

@Willers-Yang Willers-Yang commented Apr 8, 2023

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.

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
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Apr 8, 2023
@qiskit-bot
Copy link
Collaborator

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:

  • @Qiskit/terra-core

@CLAassistant
Copy link

CLAassistant commented Apr 8, 2023

CLA assistant check
All committers have signed the CLA.

@ShellyGarion ShellyGarion added synthesis Changelog: New Feature Include in the "Added" section of the changelog labels Apr 9, 2023
@coveralls
Copy link

coveralls commented Apr 9, 2023

Pull Request Test Coverage Report for Build 5522429506

  • 112 of 112 (100.0%) changed or added relevant lines in 4 files are covered.
  • 190 unchanged lines in 12 files lost coverage.
  • Overall coverage decreased (-0.002%) to 85.984%

Files with Coverage Reduction New Missed Lines %
qiskit/qasm/init.py 1 80.0%
qiskit/synthesis/clifford/clifford_decompose_layers.py 1 93.83%
qiskit/extensions/quantum_initializer/squ.py 2 80.0%
crates/qasm2/src/lex.rs 3 90.89%
qiskit/qasm/pygments/init.py 3 0%
qiskit/circuit/bit.py 5 90.0%
qiskit/quantum_info/states/utils.py 6 93.48%
qiskit/qpy/binary_io/circuits.py 11 92.95%
qiskit/qasm/pygments/lexer.py 14 0%
crates/qasm2/src/parse.rs 18 96.18%
Totals Coverage Status
Change from base Build 5490783039: -0.002%
Covered Lines: 71741
Relevant Lines: 83435

💛 - Coveralls

Copy link
Member

@ShellyGarion ShellyGarion left a 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:

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

qiskit/synthesis/clifford/clifford_decompose_layers.py Outdated Show resolved Hide resolved
@ShellyGarion ShellyGarion added this to the 0.25.0 milestone Apr 9, 2023
@ShellyGarion ShellyGarion self-assigned this Apr 10, 2023
@ShellyGarion
Copy link
Member

@Willers-Yang - thank you for addressing my comments, and fixing the style errors.
Now, one should also prepare the documentation that will eventually appear here: https://qiskit.org/documentation/apidoc/synthesis.html.

First, you should add the new function synth_cx_cz_line_my to qiskit/synthesis/linear_phase/__init__.py and to qiskit/synthesis/__init__.py (in two places).

Second, could you please add release notes?
https://github.com/Qiskit/qiskit-terra/blob/main/CONTRIBUTING.md#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.

Copy link
Member

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

Copy link
Member

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

qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py Outdated Show resolved Hide resolved
qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py Outdated Show resolved Hide resolved
qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py Outdated Show resolved Hide resolved
qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py Outdated Show resolved Hide resolved
qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py Outdated Show resolved Hide resolved
qiskit/synthesis/clifford/clifford_decompose_layers.py Outdated Show resolved Hide resolved
qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py Outdated Show resolved Hide resolved
qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py Outdated Show resolved Hide resolved
@ShellyGarion ShellyGarion removed the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jun 12, 2023
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),
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor

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

@Willers-Yang
Copy link
Contributor Author

@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!

ShellyGarion
ShellyGarion previously approved these changes Jul 10, 2023
@alexanderivrii alexanderivrii added this pull request to the merge queue Jul 12, 2023
Merged via the queue into Qiskit:main with commit 9f84f26 Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog synthesis
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants