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

Synthesis of CZ and Clifford circuits for linear nearest neighbor connectivity #9450

Merged
merged 25 commits into from
Feb 23, 2023

Conversation

ShellyGarion
Copy link
Member

@ShellyGarion ShellyGarion commented Jan 25, 2023

Summary

#9036

Synthesis of a CZ circuit for linear nearest neighbor (LNN) connectivity in 2-qubit depth of 2n+2 using CX and phase gates (S, Sdg or Z). Note that the synthesized circuit reverts the order of the qubits.

This CZ synthesis method allows to synthesize a Clifford circuit for LNN connectivity in 2-qubit depth of 9n+4 (which is still not optimal), by using the layered Clifford synthesis (clifford_decompose_layers.py) and linear_depth_lnn.py for synthesizing the CX layer in depth 5n.

This PR will be followed by another PR based on a paper of Maslov and Yang (https://arxiv.org/abs/2210.16195), that synthesize the CX-CZ layers in depth 5n for LNN connectivity, and hence reduce the depth of a Clifford circuit to 7n-4 for LNN connectivity.

Details and comments

The algorithm is based on the paper of Maslov and Roetteler https://arxiv.org/abs/1705.09176

image

@ShellyGarion ShellyGarion added this to the 0.24.0 milestone Jan 25, 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

@mtreinish mtreinish added the Changelog: New Feature Include in the "Added" section of the changelog label Jan 25, 2023
@ShellyGarion ShellyGarion changed the title [WIP] Synthesis of a CZ circuit for linear nearest neighbor connectivity [WIP] Synthesis of CZ and Clifford circuits for linear nearest neighbor connectivity Jan 29, 2023
@coveralls
Copy link

coveralls commented Jan 29, 2023

Pull Request Test Coverage Report for Build 4252380784

  • 157 of 159 (98.74%) changed or added relevant lines in 7 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.03%) to 85.336%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/synthesis/linear/linear_circuits_utils.py 9 11 81.82%
Files with Coverage Reduction New Missed Lines %
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 1 94.93%
qiskit/extensions/quantum_initializer/squ.py 2 80.0%
Totals Coverage Status
Change from base Build 4245835942: 0.03%
Covered Lines: 67458
Relevant Lines: 79050

💛 - Coveralls

@ShellyGarion ShellyGarion changed the title [WIP] Synthesis of CZ and Clifford circuits for linear nearest neighbor connectivity Synthesis of CZ and Clifford circuits for linear nearest neighbor connectivity Jan 29, 2023
@ShellyGarion
Copy link
Member Author

This PR is ready for an initial review (mainly of the API). It only misses the release notes.

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.

Thanks Shelly! I took a quick look at the code and overall it seems quite solid. My main question was whether we can extend the interface to allow "cz-layer-synthesis-with-reversal" function instead of hard-coding the function name.

qiskit/synthesis/clifford/clifford_decompose_layers.py Outdated Show resolved Hide resolved
qiskit/synthesis/linear/cz_depth_lnn.py Outdated Show resolved Hide resolved
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.

Thanks @ShellyGarion! The PR looks very good. I only had very minor comments at this point.

qiskit/synthesis/__init__.py Outdated Show resolved Hide resolved
Comment on lines 99 to 103
from .linear import (
synth_cnot_count_full_pmh,
synth_cnot_depth_line_kms,
synth_cz_depth_line_mr,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion on this either. Does it make sense that code for CZ synthesis appears under linear? Or would it be better to put it in the synthesis/cz subdirectory?

Copy link
Member Author

@ShellyGarion ShellyGarion Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the best solution is to have another folder of synthesis/linear_phase since the cz synthesis is into cx and phase gates, and relies on the theory of phase polynomials. It's similar to graysynth that should be moved this folder too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving and renaming graysynth, as well as deprecating https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/transpiler/synthesis/graysynth.py will be done in a separate PR

qiskit/synthesis/clifford/clifford_decompose_layers.py Outdated Show resolved Hide resolved
qiskit/synthesis/linear/cz_depth_lnn.py Outdated Show resolved Hide resolved
test/python/synthesis/test_cz_synthesis.py Outdated Show resolved Hide resolved
test/python/synthesis/test_cz_synthesis.py Show resolved Hide resolved
alexanderivrii
alexanderivrii previously approved these changes Feb 23, 2023
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.

Thanks Shelly, looks very good. I have asked for two tiny-tiny fixes, after that it's good to go.

qiskit/synthesis/__init__.py Show resolved Hide resolved
qiskit/synthesis/__init__.py Outdated Show resolved Hide resolved
@mergify mergify bot merged commit 158563f into Qiskit:main Feb 23, 2023
Eric-Arellano pushed a commit to Eric-Arellano/qiskit-terra that referenced this pull request Feb 23, 2023
…nectivity (Qiskit#9450)

* add cz synthesis for LNN

* basic cz synthesis test

* adjust clifford_decompose_layers to cz synthesis for LNN

* add a basic test for layered clifford synthesis for LNN

* enhance the tests

* fix lint, check function name

* Add utils needed for LNN tests

* add tests for LNN and depth

* Add documentation for cz synthesis

* fix misprint

* add synth_clifford_depth_lnn

* updates following review

* rename synth_clifford_depth_lnn

* update references

* remove a util function that is not needed

* update docstring

* add release notes

* replace int(n/2) by n//2

* reduce the number of 1-qubit gates

* fix test

* refactor and minor changes following review

* update docs

* update init file following review

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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
None yet
Development

Successfully merging this pull request may close these issues.

5 participants