Skip to content

Deprecate qiskit/quantum_info/synthesis and move to qiskit/synthesis (backport #11460) #11635

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

Merged
merged 7 commits into from
Jan 26, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jan 24, 2024

This is an automatic backport of pull request #11460 done by Mergify.
Cherry-pick of 8887f44 has failed:

On branch mergify/bp/stable/0.46/pr-11460
Your branch is up to date with 'origin/stable/0.46'.

You are currently cherry-picking commit 8887f4436.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   qiskit/circuit/library/generalized_gates/rv.py
	modified:   qiskit/circuit/library/generalized_gates/uc.py
	modified:   qiskit/circuit/library/generalized_gates/unitary.py
	modified:   qiskit/circuit/library/pauli_evolution.py
	modified:   qiskit/circuit/library/standard_gates/equivalence_library.py
	modified:   qiskit/quantum_info/__init__.py
	renamed:    qiskit/quantum_info/synthesis/quaternion.py -> qiskit/quantum_info/quaternion.py
	modified:   qiskit/quantum_info/synthesis/__init__.py
	deleted:    qiskit/quantum_info/synthesis/clifford_decompose.py
	deleted:    qiskit/quantum_info/synthesis/cnotdihedral_decompose.py
	modified:   qiskit/quantum_info/synthesis/ion_decompose.py
	deleted:    qiskit/quantum_info/synthesis/qsd.py
	new file:   qiskit/synthesis/one_qubit/__init__.py
	renamed:    qiskit/quantum_info/synthesis/one_qubit_decompose.py -> qiskit/synthesis/one_qubit/one_qubit_decompose.py
	new file:   qiskit/synthesis/two_qubit/__init__.py
	renamed:    qiskit/quantum_info/synthesis/local_invariance.py -> qiskit/synthesis/two_qubit/local_invariance.py
	renamed:    qiskit/quantum_info/synthesis/two_qubit_decompose.py -> qiskit/synthesis/two_qubit/two_qubit_decompose.py
	renamed:    qiskit/quantum_info/synthesis/weyl.py -> qiskit/synthesis/two_qubit/weyl.py
	renamed:    qiskit/quantum_info/synthesis/xx_decompose/__init__.py -> qiskit/synthesis/two_qubit/xx_decompose/__init__.py
	renamed:    qiskit/quantum_info/synthesis/xx_decompose/circuits.py -> qiskit/synthesis/two_qubit/xx_decompose/circuits.py
	renamed:    qiskit/quantum_info/synthesis/xx_decompose/decomposer.py -> qiskit/synthesis/two_qubit/xx_decompose/decomposer.py
	renamed:    qiskit/quantum_info/synthesis/xx_decompose/embodiments.py -> qiskit/synthesis/two_qubit/xx_decompose/embodiments.py
	renamed:    qiskit/quantum_info/synthesis/xx_decompose/paths.py -> qiskit/synthesis/two_qubit/xx_decompose/paths.py
	renamed:    qiskit/quantum_info/synthesis/xx_decompose/polytopes.py -> qiskit/synthesis/two_qubit/xx_decompose/polytopes.py
	renamed:    qiskit/quantum_info/synthesis/xx_decompose/utilities.py -> qiskit/synthesis/two_qubit/xx_decompose/utilities.py
	renamed:    qiskit/quantum_info/synthesis/xx_decompose/weyl.py -> qiskit/synthesis/two_qubit/xx_decompose/weyl.py
	modified:   qiskit/transpiler/passes/optimization/consolidate_blocks.py
	modified:   qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py
	modified:   qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py
	modified:   qiskit/transpiler/passes/optimization/optimize_1q_gates.py
	modified:   qiskit/transpiler/passes/scheduling/dynamical_decoupling.py
	modified:   qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py
	modified:   qiskit/transpiler/passes/synthesis/unitary_synthesis.py
	new file:   releasenotes/notes/deprecate-qinfo-synthesis-23abd8c34fc0f52e.yaml
	modified:   test/benchmarks/quantum_info.py
	modified:   test/python/quantum_info/test_quaternions.py
	renamed:    test/python/quantum_info/test_local_invariance.py -> test/python/synthesis/test_local_invariance.py
	renamed:    test/python/quantum_info/test_synthesis.py -> test/python/synthesis/test_synthesis.py
	renamed:    test/python/quantum_info/test_weyl.py -> test/python/synthesis/test_weyl.py
	renamed:    test/python/quantum_info/xx_decompose/__init__.py -> test/python/synthesis/xx_decompose/__init__.py
	renamed:    test/python/quantum_info/xx_decompose/test_circuits.py -> test/python/synthesis/xx_decompose/test_circuits.py
	renamed:    test/python/quantum_info/xx_decompose/test_decomposer.py -> test/python/synthesis/xx_decompose/test_decomposer.py
	renamed:    test/python/quantum_info/xx_decompose/test_polytopes.py -> test/python/synthesis/xx_decompose/test_polytopes.py
	renamed:    test/python/quantum_info/xx_decompose/test_weyl.py -> test/python/synthesis/xx_decompose/test_weyl.py
	renamed:    test/python/quantum_info/xx_decompose/utilities.py -> test/python/synthesis/xx_decompose/utilities.py
	modified:   test/python/transpiler/test_echo_rzx_weyl_decomposition.py
	modified:   test/randomized/test_synthesis.py

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   qiskit/synthesis/__init__.py
	added by them:   qiskit/transpiler/synthesis/qsd.py
	both modified:   test/benchmarks/random_circuit_hex.py

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/github/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally


Mergify commands and options

More conditions and actions can be found in the documentation.

You can also trigger Mergify actions by commenting on this pull request:

  • @Mergifyio refresh will re-evaluate the rules
  • @Mergifyio rebase will rebase this PR on its base branch
  • @Mergifyio update will merge the base branch into this PR
  • @Mergifyio backport <destination> will backport this PR on <destination> branch

Additionally, on Mergify dashboard you can:

  • look at your merge queues
  • generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com

…11460)

* remove deprecated code in clifford_decompose and cnotdihedral_decompose

* move tests from test/python/quantum_info to test/python/synthesis

* move the Quaternion class from quantum_info/synthesis to quantum_info

* deprecate cnot_rxx_decompose, and move to an internal code in the equivalence_library

* deprecate cnot_rxx_decompose

* move qsd from qiskit/quantum_info/synthesis to qiskit/synthesis/unitary

* handle lint and docs errors in qsd

* handle lint and docs errors in qsd

* handle lint and docs errors in qsd

* handle lint and docs errors in qsd

* handle lint and docs errors in qsd

* handle cyclic imports in qsd

* minor

* update qsd docs

* move one_qubit_decompose from qiskit/quantum_info/synthesis to qiskit/synthesis/one_qubit

* move xx_decompose from qiskit/quantum_info/synthesis to qiskit/synthesis/two_qubits

* handle cyclic imports

* move two-qubit synthesis code from qiskit/quantum_info/synthesis to qiskit/synthesis/two_qubits

* update qsd docs

* minor

* add release notes

* updates following review

* add disable cyclic import to rv.py

* add deprecation warning in qiskit/quantum_info/__init__.py

* fix links

* improve qsd docs following review

* update qsd after review

* change pending deprecatrion to deprecation in ion_decompose

* update release notes following review

* update pending deprecation to deprecation

* add test for a deprecation

* add more tests for deprecations

* add another test for deprecation

* handle lint errors

* minor fix following review

* remove test for _cnot_rxx_decompose() private method

(cherry picked from commit 8887f44)

# Conflicts:
#	qiskit/synthesis/__init__.py
#	qiskit/transpiler/synthesis/qsd.py
#	test/benchmarks/random_circuit_hex.py
@mergify mergify bot added the conflicts used by mergify when there are conflicts in a port label Jan 24, 2024
@mergify mergify bot requested review from a team and ikkoham as code owners January 24, 2024 14:41
@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:

  • @Cryoris
  • @Qiskit/terra-core
  • @ajavadia
  • @ikkoham
  • @levbishop

@github-actions github-actions bot added Changelog: Deprecation Include in "Deprecated" section of changelog Changelog: Removal Include in the Removed section of the changelog labels Jan 24, 2024
@github-actions github-actions bot added this to the 0.46.0 milestone Jan 24, 2024
@coveralls
Copy link

coveralls commented Jan 25, 2024

Pull Request Test Coverage Report for Build 7657440342

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 86.948%

Totals Coverage Status
Change from base Build 7653065220: 0.03%
Covered Lines: 74326
Relevant Lines: 85483

💛 - Coveralls

ShellyGarion
ShellyGarion previously approved these changes Jan 25, 2024
@ShellyGarion ShellyGarion self-requested a review January 25, 2024 16:44
@Cryoris Cryoris added Changelog: New Feature Include in the "Added" section of the changelog and removed conflicts used by mergify when there are conflicts in a port labels Jan 26, 2024
@Cryoris Cryoris added this pull request to the merge queue Jan 26, 2024
Merged via the queue into stable/0.46 with commit 0dd2212 Jan 26, 2024
@mergify mergify bot deleted the mergify/bp/stable/0.46/pr-11460 branch January 26, 2024 16:46
@garrison
Copy link
Member

This backport has broken CI for the circuit-knitting-toolbox. See e.g. https://github.com/Qiskit-Extensions/circuit-knitting-toolbox/actions/runs/7689870643/job/20952914803.

If this change is to be performed in a backwards compatible way, then the following import line should be made to still work in the backported version:

from qiskit.quantum_info.synthesis.two_qubit_decompose import TwoQubitWeylDecomposition

@jakelishman
Copy link
Member

Jim: is there a reason you need that hyperspeciifc import? We don't consider particular modules beyond a package's __init__ to be public details, so unless there's a real problem, I'd consider the circuit knitting toolbox to have been using a private implementation detail before.

@garrison
Copy link
Member

Jim: is there a reason you need that hyperspeciifc import? We don't consider particular modules beyond a package's __init__ to be public details, so unless there's a real problem, I'd consider the circuit knitting toolbox to have been using a private implementation detail before.

That class is not imported in synthesis/__init__.py, so I suppose the problem, then, is that we are relying on a private class --
not just import location -- is that that right? The very extensive docstrings led me to believe it was meant to be a public interface. I've been wondering why this class is not part of the Sphinx build, but maybe now I finally have learned the real reason for this ...

@jakelishman
Copy link
Member

Ah, sorry, I'd assumed it was imported into the package and documented. In this case yeah, I think it probably was meant to be public but it's one of the old parts of Terra where the public/private split is not handled well.

I think in the interests of practicality we ought to make your import work on the backport branch, and ensure that the new location correctly imports it into the package and documents it.

@ShellyGarion - would you be able to look at doing that?

@ShellyGarion
Copy link
Member

ShellyGarion commented Jan 30, 2024

@garrison - I also thought that this was an internal class, since it has never appeared in the docs before (and also not in qiskit.quantum_info.__init__ or in qiskit.quantum_info.synthesis.__init__).

Anyway, it was not removed, only migrated to the synthesis library, here:

class TwoQubitWeylDecomposition:

So, an immediate solution would be to replace your line above:
from qiskit.quantum_info.synthesis.two_qubit_decompose import TwoQubitWeylDecomposition
by the following line:
from qiskit.synthesis.two_qubit.two_qubit_decompose import TwoQubitWeylDecomposition

@ShellyGarion
Copy link
Member

To provide a solution for the long run, perhaps you could provide a link to the circuit knitting code that uses this class?
Do you know why it uses it and not the class TwoQubitBasisDecomposer ?
If this is an important and useful class, then we can properly add it to the qiskit.synthesis init file and documentation.
(is there enough time to do it for Qiskit 1.0 release?)

@ShellyGarion
Copy link
Member

This PR: #11672
should make the current import code work as is, and raise a deprecation warning.

garrison added a commit to Qiskit/qiskit-addon-cutting that referenced this pull request Apr 12, 2024
…ion`

This is a follow-up to the conversation at
Qiskit/qiskit#11635 (comment).

The toplevel package import was made available in
Qiskit/qiskit#11687
in time for Qiskit 1.0.
garrison added a commit to Qiskit/qiskit-addon-cutting that referenced this pull request Apr 12, 2024
…ion` (#547)

This is a follow-up to the conversation at
Qiskit/qiskit#11635 (comment).

The toplevel package import was made available in
Qiskit/qiskit#11687
in time for Qiskit 1.0.
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 Changelog: New Feature Include in the "Added" section of the changelog Changelog: Removal Include in the Removed section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants