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

Transfer clifford and cnot-dihedral synthesis functions from quantum_info to synthesis #9141

Merged
merged 16 commits into from
Nov 30, 2022

Conversation

ShellyGarion
Copy link
Member

@ShellyGarion ShellyGarion commented Nov 16, 2022

Summary

Transfer Clifford and CNOT-Dihedral synthesis functions from qiskit/quantum_info/synthesis to qiskit/synthesis

Details and comments

The functions decompose_clifford and decompose_cnotdihedral will be deprecated, renamed and moved to qiskit/quantum_info/synthesis.

@ShellyGarion ShellyGarion requested review from a team and alexanderivrii as code owners November 16, 2022 13:32
@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:

@ShellyGarion ShellyGarion requested a review from ikkoham November 16, 2022 14:05
@coveralls
Copy link

coveralls commented Nov 16, 2022

Pull Request Test Coverage Report for Build 3583929747

  • 689 of 714 (96.5%) changed or added relevant lines in 15 files are covered.
  • 6 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.02%) to 84.578%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/synthesis/clifford/clifford_decompose_ag.py 76 77 98.7%
qiskit/synthesis/clifford/clifford_decompose_full.py 11 13 84.62%
qiskit/synthesis/clifford/clifford_decompose_greedy.py 177 179 98.88%
qiskit/synthesis/clifford/clifford_decompose_bm.py 134 137 97.81%
qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_general.py 72 75 96.0%
qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_two_qubits.py 192 195 98.46%
qiskit/quantum_info/synthesis/clifford_decompose.py 2 7 28.57%
qiskit/quantum_info/synthesis/cnotdihedral_decompose.py 0 6 0.0%
Files with Coverage Reduction New Missed Lines %
qiskit/quantum_info/synthesis/cnotdihedral_decompose.py 3 0%
qiskit/quantum_info/synthesis/clifford_decompose.py 3 30.77%
Totals Coverage Status
Change from base Build 3576547582: -0.02%
Covered Lines: 62967
Relevant Lines: 74448

💛 - Coveralls

@ShellyGarion ShellyGarion changed the title [WIP] Transfer clifford and cnot-dihedral synthesis functions from quantum_info to synthesis Transfer clifford and cnot-dihedral synthesis functions from quantum_info to synthesis Nov 23, 2022
@ShellyGarion
Copy link
Member Author

This PR is almost done (only needs release notes). I would like to approve the API before that.

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. I agree that moving synthesis algorithms for Clifford and CNOTDihedral into the qiskit/synthesis directory makes a lot of sense and makes the code structure a bit cleaner. As far as I can judge, this PR does not do any algorithmic changes (modulo some minor renaming), so overall this looks good to me.

One minor question that I had is whether we still need clifford_decompose.py and cnotdihedral_decompose.py files in the quantum_info/synthesis directory. This is not by any means a suggestion to remove these files, it's only a question if you think we need them in the long run?

The renamed function names (such as synch_clifford_ag instead of decompose_clifford_ag) are completely fine, I don't think we really needed to rename these, but I do like the new version slightly better, and maybe we are implicitly converging to a convention that synthesis functions in the qiskit/synthesis directory should start with synth.

Since now Clifford and CNOTDihedral synthesis methods (such as synth_clifford_ag, synth_cnotdihedral_full, etc.) are part of the official documentation, it makes sense to add some release notes.

Copy link
Contributor

@ikkoham ikkoham 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. The direction is nice.
I'm concerned about circular dependencies between quantum_info and synthesis. I think it would be nice that synthesis depends on quantum_info and synthesis should not depend on quantum_info. It is good to be dependent only during the deprecation period. It is transient.
I only wrote comments in one place because I didn't want to write the same again, but there are many similar comments.

And also could you add tests for synthesis and release note?

# ---------------------------------------------------------------------


def decompose_clifford_bm(clifford):
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing these public functions are API breaking, so could you add deprecation warning?

Copy link
Member Author

Choose a reason for hiding this comment

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

These functions are internal and not part of the API. The only function appearing in the docs is decompose_clifford:
https://qiskit.org/documentation/apidoc/quantum_info.html#synthesis

Copy link
Contributor

Choose a reason for hiding this comment

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

I found it in https://qiskit.org/documentation/apidoc/transpiler_synthesis_plugins.html?highlight=decompose_clifford_bm#high-level-synthesis-plugins.
The issue is what is a public API in Qiskit. More to the point, I think the question is whether there are users... (if you don't think there are no users, I'm fine)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching this! I fixed the documentation accordingly.

@ShellyGarion ShellyGarion added this to the 0.23.0 milestone Nov 24, 2022
@ShellyGarion
Copy link
Member Author

Thank you @alexanderivrii and @ikkoham for your reviews!
As suggested, I deprecated the functions decompose_clifford and decompose_cnotdihedral, and transferred their code to qiskit.synthesis. There is no need to deprecate their sub-functions, since they have never appeared in Qiskit API docs.
I also added release notes and some tests.

Copy link
Contributor

@ikkoham ikkoham 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! Only one more issue remains.

# ---------------------------------------------------------------------


def decompose_clifford_bm(clifford):
Copy link
Contributor

Choose a reason for hiding this comment

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

I found it in https://qiskit.org/documentation/apidoc/transpiler_synthesis_plugins.html?highlight=decompose_clifford_bm#high-level-synthesis-plugins.
The issue is what is a public API in Qiskit. More to the point, I think the question is whether there are users... (if you don't think there are no users, I'm fine)

@alexanderivrii
Copy link
Contributor

Thank you! Only one more issue remains.

@ikkoham, thanks for spotting this. This is a really new feature, and I don't think anyone is really using it yet, so it should probably be ok to just change the documentation without issuing a deprecation warning.

@ShellyGarion ShellyGarion requested a review from ikkoham November 29, 2022 08:47
@ikkoham
Copy link
Contributor

ikkoham commented Nov 30, 2022

@alexanderivrii Thanks. I understand the situation. I think it's good.

Copy link
Contributor

@ikkoham ikkoham 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. LGTM!

@ikkoham ikkoham added Changelog: Deprecation Include in "Deprecated" section of changelog automerge labels Nov 30, 2022
@mergify mergify bot merged commit 0785ab3 into Qiskit:main Nov 30, 2022
Cryoris pushed a commit to Cryoris/qiskit-terra that referenced this pull request Jan 12, 2023
…info to synthesis (Qiskit#9141)

* transfer clifford synthesis functions from quantum_info to synthesis

* add init file

* transfer cnotdihedral synthesis from quantum_info to synthesis

* rename clifford synth functions. add docs

* add clifford synthesis methods to docs

* add documentation for cnotdihedral synth methods

* add decompose_cnotdihedral to quantum_info docs

* deprecate decompose_clifford and decompose_cnotdihedral - move to qsikit.synthesis

* style

* add clifford and cnotdihedral decompose full to synthesis

* enhance tests

* update high_level_synthesis transpiler pass

* add release notes

* fix docs in synthesis plugin

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: Deprecation Include in "Deprecated" section of changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants