Skip to content

Commit

Permalink
Remove qiskit.transpiler.synthesis for Qiskit 1.0 release (#11570)
Browse files Browse the repository at this point in the history
* deprecate transpiler/synthesis/graysynth.py

* style

* style

* move aqc_plugin to qiskit/transpiler/passes/synthesis

* remove code from qiskit/transpiler/synthesis/aqc/aqc_plugin.py

* copy qiskit/transpiler/synthesis/aqc to qiskit/synthesis/unitary

* move tests from test/python/transpiler/aqc to test/python/synthesis/aqc

* update imports in aqc_plugin

* add deprecation warning to AQC module

* handle cyclic imports

* handle cyclic imports

* update link in docs

* update init in qiskit/transpiler/synthesis/aqc

* style

* temporary remove deprecation warning test

* remove files from qiskit/transpiler/synthesis/aqc

* update link in test

* add release notes

* update docs

* update docs/apidocs/synthesis_aqc.rst

* add deprecations to qiskit/transpiler/synthesis/__init__.py

* fix link

* remove qiskit/transpiler/synthesis

* add release notes

* improve docs

* add import aqc to qiskit.synthesis

* fix lint errors
  • Loading branch information
ShellyGarion authored Jan 25, 2024
1 parent 3364ba5 commit 1c20b84
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 214 deletions.
16 changes: 0 additions & 16 deletions qiskit/transpiler/synthesis/__init__.py

This file was deleted.

37 changes: 0 additions & 37 deletions qiskit/transpiler/synthesis/aqc/__init__.py

This file was deleted.

123 changes: 0 additions & 123 deletions qiskit/transpiler/synthesis/graysynth.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
upgrade:
- |
Removed the ``qiskit.transpiler.synthesis`` module, which has been deprecated since the 0.46 release.
The following objects have been moved:
* :mod:`qiskit.transpiler.synthesis.aqc` has been moved to :mod:`qiskit.synthesis.unitary.aqc`
(except of :class:`qiskit.synthesis.unitary.aqc.AQCSynthesisPlugin`).
* :class:`qiskit.synthesis.unitary.aqc.AQCSynthesisPlugin` has been moved to
:class:`qiskit.transpiler.passes.synthesis.AQCSynthesisPlugin`.
* :func:`qiskit.transpiler.synthesis.graysynth` has been moved to
:func:`qiskit.synthesis.synth_cnot_phase_aam`.
* :func:`qiskit.transpiler.synthesis.cnot_synth` has been moved to
:func:`qiskit.synthesis.synth_cnot_count_full_pmh`.
6 changes: 0 additions & 6 deletions test/python/synthesis/aqc/test_aqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,6 @@ def test_aqc_determinant_minus_one(self):
error = 0.5 * (np.linalg.norm(approx_matrix - target_matrix, "fro") ** 2)
self.assertTrue(error < 1e-3)

def test_deprecation(self):
"""Test that importing this module is deprecated."""
# pylint: disable = unused-import
with self.assertWarns(DeprecationWarning):
import qiskit.transpiler.synthesis.aqc


if __name__ == "__main__":
unittest.main()
40 changes: 8 additions & 32 deletions test/python/synthesis/test_cnot_phase_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,14 @@
from qiskit.quantum_info.operators import Operator
from qiskit.synthesis.linear import synth_cnot_count_full_pmh
from qiskit.synthesis.linear_phase import synth_cnot_phase_aam
from qiskit.transpiler.synthesis.graysynth import (
cnot_synth,
graysynth,
)
from qiskit.test import QiskitTestCase


@ddt.ddt
class TestGraySynth(QiskitTestCase):
"""Test the Gray-Synth algorithm."""

@ddt.data(synth_cnot_phase_aam, graysynth)
def test_gray_synth(self, synth_func):
def test_gray_synth(self):
"""Test synthesis of a small parity network via gray_synth.
The algorithm should take the following matrix as an input:
Expand Down Expand Up @@ -75,11 +70,7 @@ def test_gray_synth(self, synth_func):
[0, 1, 0, 0, 1, 0],
]
angles = ["s", "t", "z", "s", "t", "t"]
if synth_func.__name__ == "graysynth":
with self.assertWarns(DeprecationWarning):
c_gray = synth_func(cnots, angles)
else:
c_gray = synth_func(cnots, angles)
c_gray = synth_cnot_phase_aam(cnots, angles)
unitary_gray = UnitaryGate(Operator(c_gray))

# Create the circuit displayed above:
Expand Down Expand Up @@ -108,8 +99,7 @@ def test_gray_synth(self, synth_func):
# Check if the two circuits are equivalent
self.assertEqual(unitary_gray, unitary_compare)

@ddt.data(synth_cnot_phase_aam, graysynth)
def test_paper_example(self, synth_func):
def test_paper_example(self):
"""Test synthesis of a diagonal operator from the paper.
The diagonal operator in Example 4.2
Expand Down Expand Up @@ -137,11 +127,7 @@ def test_paper_example(self, synth_func):
"""
cnots = [[0, 1, 1, 1, 1, 1], [1, 0, 0, 1, 1, 1], [1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0]]
angles = ["t"] * 6
if synth_func.__name__ == "graysynth":
with self.assertWarns(DeprecationWarning):
c_gray = synth_func(cnots, angles)
else:
c_gray = synth_func(cnots, angles)
c_gray = synth_cnot_phase_aam(cnots, angles)
unitary_gray = UnitaryGate(Operator(c_gray))

# Create the circuit displayed above:
Expand All @@ -167,8 +153,7 @@ def test_paper_example(self, synth_func):
# Check if the two circuits are equivalent
self.assertEqual(unitary_gray, unitary_compare)

@ddt.data(synth_cnot_phase_aam, graysynth)
def test_ccz(self, synth_func):
def test_ccz(self):
"""Test synthesis of the doubly-controlled Z gate.
The diagonal operator in Example 4.3
Expand All @@ -194,11 +179,7 @@ def test_ccz(self, synth_func):
"""
cnots = [[1, 0, 0, 1, 1, 0, 1], [0, 1, 0, 1, 0, 1, 1], [0, 0, 1, 0, 1, 1, 1]]
angles = ["t", "t", "t", "tdg", "tdg", "tdg", "t"]
if synth_func.__name__ == "graysynth":
with self.assertWarns(DeprecationWarning):
c_gray = synth_func(cnots, angles)
else:
c_gray = synth_func(cnots, angles)
c_gray = synth_cnot_phase_aam(cnots, angles)
unitary_gray = UnitaryGate(Operator(c_gray))

# Create the circuit displayed above:
Expand Down Expand Up @@ -228,8 +209,7 @@ class TestPatelMarkovHayes(QiskitTestCase):
"""Test the Patel-Markov-Hayes algorithm for synthesizing linear
CNOT-only circuits."""

@ddt.data(synth_cnot_count_full_pmh, cnot_synth)
def test_patel_markov_hayes(self, synth_func):
def test_patel_markov_hayes(self):
"""Test synthesis of a small linear circuit
(example from paper, Figure 3).
Expand Down Expand Up @@ -264,11 +244,7 @@ def test_patel_markov_hayes(self, synth_func):
[1, 1, 0, 1, 1, 1],
[0, 0, 1, 1, 1, 0],
]
if synth_func.__name__ == "cnot_synth":
with self.assertWarns(DeprecationWarning):
c_patel = synth_func(state)
else:
c_patel = synth_func(state)
c_patel = synth_cnot_count_full_pmh(state)
unitary_patel = UnitaryGate(Operator(c_patel))

# Create the circuit displayed above:
Expand Down

0 comments on commit 1c20b84

Please sign in to comment.