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

Improve LinearFunction synthesis #8568

Merged
merged 44 commits into from
Nov 3, 2022
Merged

Conversation

ShellyGarion
Copy link
Member

@ShellyGarion ShellyGarion commented Aug 17, 2022

Summary

close #8519

Details and comments

  • move graysynth.py from qiskit.transpiler to qiskit.synthesis.linear
  • move test_synthesis.py from test/python/transpiler- where?
  • add a function that tries to synthesize A, A^{-1}, A^t and A^{-t} and choose the best CX cost and/or depth
  • add a util function for inverting a linear binary matrix
  • add a util function for generating a random linear binary matrix (also useful for the CNOTDihedral class)
  • change the transpiler pass of LinearFunctionsSynthesis so it will not return a circuit if it has more CX gates and/or worse depth than the original circuit.
  • add tests and docstrings

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

@coveralls
Copy link

coveralls commented Aug 17, 2022

Pull Request Test Coverage Report for Build 3385868016

  • 122 of 129 (94.57%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 84.542%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/transpiler/passes/synthesis/high_level_synthesis.py 1 2 50.0%
qiskit/synthesis/linear/linear_circuits_utils.py 44 46 95.65%
qiskit/synthesis/linear/linear_matrix_utils.py 66 70 94.29%
Totals Coverage Status
Change from base Build 3385852241: 0.02%
Covered Lines: 62450
Relevant Lines: 73869

💛 - Coveralls

Copy link
Member

@ajavadia ajavadia left a comment

Choose a reason for hiding this comment

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

can you please add a new test that shows #8519 is fixed?

@ShellyGarion
Copy link
Member Author

can you please add a new test that shows #8519 is fixed?

Since this PR is already quite long, it's better that this PR will handle only the necessarily linear utils, and we would take care of the transpiler passes in a following PR, preferably after #8548 will get merged.

alexanderivrii
alexanderivrii previously approved these changes Oct 25, 2022
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, LGTM!

@alexanderivrii alexanderivrii added this to the 0.23.0 milestone Oct 30, 2022
Copy link
Member

@kdk kdk left a comment

Choose a reason for hiding this comment

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

This looks great @ShellyGarion ! A few small questions:

  • Is there a similar plan to move the AQC code to qiskit/synthesis?
  • What was the decision on renaming cnot_synth to PMH_cnot_synth?

These functions were in a bit of an unusual state in that they were in some ways internal (not exported by default, did not appear in documentation) and in some ways public (docstring commented, name didn't start with leading _). It'd be nice if they could fall one way or the other. @mtreinish Are there other examples of code in a similar state?

@ShellyGarion
Copy link
Member Author

ShellyGarion commented Nov 2, 2022

  • Is there a similar plan to move the AQC code to qiskit/synthesis?

  • What was the decision on renaming cnot_synth to PMH_cnot_synth?

These functions were in a bit of an unusual state in that they were in some ways internal (not exported by default, did not appear in documentation) and in some ways public (docstring commented, name didn't start with leading _). It'd be nice if they could fall one way or the other. @mtreinish Are there other examples of code in a similar state?

  • We agree that AQC should be moved in the future, but this is not a part of this PR.

  • We renamed cnot_synth to synth_cnot_count_full_pmh, to indicate that the method optimizes cx gate count, and is for full connectivity. As it's still an internal function, this could be changed in following PRs if needed.

  • We're not sure if these functions should appear in the API, or only be accessible via the HLS plugin.
    For example, in clifford_decompose there are three functions for decomposing clifford circuits for full connectivity:
    decompose_clifford_ag, decompose_clifford_bm, decompose_clifford_greedy.

kdk
kdk previously approved these changes Nov 2, 2022
Copy link
Member

@kdk kdk left a comment

Choose a reason for hiding this comment

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

Thanks for the updates!

@kdk kdk added automerge Changelog: New Feature Include in the "Added" section of the changelog Changelog: API Change Include in the "Changed" section of the changelog Changelog: Bugfix Include in the "Fixed" section of the changelog labels Nov 2, 2022
@mergify mergify bot merged commit 94bccd5 into Qiskit:main Nov 3, 2022
mtreinish added a commit to mtreinish/qiskit-core that referenced this pull request Jan 24, 2023
This commit reverts a breaking change made in Qiskit#8568, in that PR the
graysynth module was moved to the qiskit.synthesis package and the
cnot_synth function was also renamed as part of the move. However, this
change would break any existing users of the module without any warning.
To fix this for the 0.23.0 release this commit adds back the graysynth
module and just exports the contents of the module in its new location.
Additionally, a small wrapper function is added so that the legacy
cnot_synth function name can continue to be used for the time being. In
the 0.24.0 cycle we can deprecate the old module and remove them after
we've giving users a warning about the change.
mtreinish added a commit to mtreinish/qiskit-core that referenced this pull request Jan 24, 2023
One release note to call out is the release note for Qiskit#8568 has been
changed significantly. This is based on Qiskit#9445 which is reverting some
breaking changes made as part of Qiskit#8568.
kdk pushed a commit that referenced this pull request Jan 24, 2023
* Add back qiskit.transpiler.passes.synthesis.graysynth module

This commit reverts a breaking change made in #8568, in that PR the
graysynth module was moved to the qiskit.synthesis package and the
cnot_synth function was also renamed as part of the move. However, this
change would break any existing users of the module without any warning.
To fix this for the 0.23.0 release this commit adds back the graysynth
module and just exports the contents of the module in its new location.
Additionally, a small wrapper function is added so that the legacy
cnot_synth function name can continue to be used for the time being. In
the 0.24.0 cycle we can deprecate the old module and remove them after
we've giving users a warning about the change.

* Restore root qiskit.transpiler.synthesis exports

* Fix import issues
mergify bot pushed a commit that referenced this pull request Jan 24, 2023
* Add back qiskit.transpiler.passes.synthesis.graysynth module

This commit reverts a breaking change made in #8568, in that PR the
graysynth module was moved to the qiskit.synthesis package and the
cnot_synth function was also renamed as part of the move. However, this
change would break any existing users of the module without any warning.
To fix this for the 0.23.0 release this commit adds back the graysynth
module and just exports the contents of the module in its new location.
Additionally, a small wrapper function is added so that the legacy
cnot_synth function name can continue to be used for the time being. In
the 0.24.0 cycle we can deprecate the old module and remove them after
we've giving users a warning about the change.

* Restore root qiskit.transpiler.synthesis exports

* Fix import issues

(cherry picked from commit bf8d6fa)
mergify bot added a commit that referenced this pull request Jan 25, 2023
…9446)

* Add back qiskit.transpiler.passes.synthesis.graysynth module

This commit reverts a breaking change made in #8568, in that PR the
graysynth module was moved to the qiskit.synthesis package and the
cnot_synth function was also renamed as part of the move. However, this
change would break any existing users of the module without any warning.
To fix this for the 0.23.0 release this commit adds back the graysynth
module and just exports the contents of the module in its new location.
Additionally, a small wrapper function is added so that the legacy
cnot_synth function name can continue to be used for the time being. In
the 0.24.0 cycle we can deprecate the old module and remove them after
we've giving users a warning about the change.

* Restore root qiskit.transpiler.synthesis exports

* Fix import issues

(cherry picked from commit bf8d6fa)

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
mergify bot pushed a commit that referenced this pull request Jan 26, 2023
* Prepare 0.23.0 release

This commit prepares the 0.23.0 release, this involves 2 steps first
changing all the version numbers to 0.23.0 from 0.23.0rc1 and secondly
updating the release notes to prepare them for publishing.

One key thing to note is that this PR removes the 0.22.0 release notes.
This is because for the 0.22.0rc1 tag we neglected to move the release
notes to a separate directory. So when we did that for the 0.22.0 final
release we had to forward port this back to main so that any backports
to stable/0.22 would be backportable (see #8901). However, this causes
reno to detect all the 0.22 release notes are incorrectly as part of the
0.23.0 development series. To fix this the simplest path forward was to
remove the 0.22.0 release notes from the 0.23.0 branch (as in this PR).

* Remove backported PRs

* Start editting release note

* More updates

* Apply suggestions from code review

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Fix docs build errors

* More udpates

* Update more release notes

One release note to call out is the release note for #8568 has been
changed significantly. This is based on #9445 which is reverting some
breaking changes made as part of #8568.

* More updates

* Finish feature note first pass

* Start upgrade notes

* Move and update new release notes

* Fix docs build error

* Finish first pass at upgrade notes

* Finish first pass at deprecation notes

* Finish first pass over release notes

* Fix import cycle from dagcircuit

* Apply suggestions from code review

Co-authored-by: Kevin Hartman <kevin@hart.mn>

* Apply suggestions from code review

Co-authored-by: Jake Lishman <jake@binhbar.com>

* Update releasenotes/notes/0.23/prepare-0.23.0-release-0d954c91143cf9a4.yaml

* Fix analysis class definition in vf2 release note

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Kevin Hartman <kevin@hart.mn>
Co-authored-by: Jake Lishman <jake@binhbar.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: API Change Include in the "Changed" section of the changelog Changelog: Bugfix Include in the "Fixed" section of the changelog 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.

Improve LinearFunction synthesis
6 participants