From 8b067ef51612a4fcec14b4b35a3d2135cc1e9fdf Mon Sep 17 00:00:00 2001 From: Takashi Imamichi Date: Fri, 10 Nov 2023 18:51:45 +0900 Subject: [PATCH 1/4] add prelude of v0.6 --- docs/migration/index.rst | 3 +++ .../notes/0.6-prelude-2740977b31d22583.yaml | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 releasenotes/notes/0.6-prelude-2740977b31d22583.yaml diff --git a/docs/migration/index.rst b/docs/migration/index.rst index 257ca60dd..15d15992f 100644 --- a/docs/migration/index.rst +++ b/docs/migration/index.rst @@ -2,6 +2,9 @@ Qiskit Optimization Migration Guide ################################### +If you are switching over to version 0.6, which has removed all previously +deprecated code, simply follow the instructions provided in the sections below. + .. nbgallery:: :glob: diff --git a/releasenotes/notes/0.6-prelude-2740977b31d22583.yaml b/releasenotes/notes/0.6-prelude-2740977b31d22583.yaml new file mode 100644 index 000000000..70e1a4d36 --- /dev/null +++ b/releasenotes/notes/0.6-prelude-2740977b31d22583.yaml @@ -0,0 +1,20 @@ +--- +prelude: > + Qiskit Optimization has been migrated to the `qiskit-community Github organization `_ + to further emphasize that it is a community-driven project. + To reflect this change and because we are onboarding additional codeowners and maintainers, + with this version (0.6) we have decided to *remove all deprecated* code, regardless of the time of its deprecation. + This ensures that the new members of the development team do not have a large bulk of legacy code to maintain. + + This can mean one of two things for you as the end-user: + + #. Nothing, if you already migrated your code and no longer rely on any deprecated features. + + #. Otherwise, you need to migrate your code immediately. If you cannot do that, or want to continue using some + of the features that were removed, you should pin your version of Qiskit Optimization to 0.5 + + You can check out the `migration guides `_ + for details on how to update your code. + + For more context on the changes around Qiskit Optimization and the other application projects as well as the algorithms + library in Qiskit, be sure to read this `blog post `_. From c3bfb224ca8d45a03854057610dd8daf97f775a8 Mon Sep 17 00:00:00 2001 From: Takashi Imamichi Date: Fri, 10 Nov 2023 22:30:08 +0900 Subject: [PATCH 2/4] add migration guide to v0.6 --- docs/migration/01_migration_guide_to_v0.5.rst | 25 +- docs/migration/02_migration_guide_to_v0.6.rst | 235 ++++++++++++++++++ .../notes/0.6-prelude-2740977b31d22583.yaml | 2 +- 3 files changed, 244 insertions(+), 18 deletions(-) create mode 100644 docs/migration/02_migration_guide_to_v0.6.rst diff --git a/docs/migration/01_migration_guide_to_v0.5.rst b/docs/migration/01_migration_guide_to_v0.5.rst index 97dd3caca..51f2a754c 100644 --- a/docs/migration/01_migration_guide_to_v0.5.rst +++ b/docs/migration/01_migration_guide_to_v0.5.rst @@ -55,23 +55,14 @@ an extension that allows users to access the eigen states. The following is the corresponding table. -+-------------------------------------+--------------------------------+ -| Former algorithm | New algorithm | -+=====================================+================================+ -| ``qis | ``qiskit. | -| kit.algorithms.MinimumEigenSolver`` | algorithms.minimum_eigensolver | -| | s.SamplingMinimumEigensolver`` | -+-------------------------------------+--------------------------------+ -| ``qiskit.a | ``qis | -| lgorithms.NumPyMinimumEigensolver`` | kit.algorithms.minimum_eigenso | -| | lver.NumPyMinimumEigensolver`` | -+-------------------------------------+--------------------------------+ -| ``qiskit.algorithms.QAOA`` | ``qiskit.algorith | -| | ms.minimum_eigensolvers.QAOA`` | -+-------------------------------------+--------------------------------+ -| ``qiskit.algorithms.VQE`` | ``qiskit.algorithms.mini | -| | mum_eigensolvers.SamplingVQE`` | -+-------------------------------------+--------------------------------+ +.. csv-table:: + :header: Former algorithm, New algorithm + + ``qiskit.algorithms.MinimumEigenSolver``, ``qiskit.algorithms.minimum_eigensolvers.SamplingMinimumEigensolver`` + ``qiskit.algorithms.NumPyMinimumEigensolver``, ``qiskit.algorithms.minimum_eigensolver.NumPyMinimumEigensolver`` + ``qiskit.algorithms.QAOA``, ``qiskit.algorithms.minimum_eigensolvers.QAOA`` + ``qiskit.algorithms.VQE``, ``qiskit.algorithms.minimum_eigensolvers.SamplingVQE`` + Setup of a problem diff --git a/docs/migration/02_migration_guide_to_v0.6.rst b/docs/migration/02_migration_guide_to_v0.6.rst new file mode 100644 index 000000000..15a3a5173 --- /dev/null +++ b/docs/migration/02_migration_guide_to_v0.6.rst @@ -0,0 +1,235 @@ +Qiskit Optimization v0.6 Migration Guide +======================================== + +This tutorial will guide you through the process of migrating your code +from Qiskit Optimization v0.5 to v0.6. + +Overview +-------- + +Qiskit Terra v0.25 deprecated the ``qiskit.algorithms`` module. It has been +superseded by a new standalone library +`Qiskit Algorithms `__. + +Qiskit Optimization v0.6 supports only the new algorithms of Qiskit Algorithms. + +It is not the intention to provide detailed explanations of the +new Qiskit Algorithms in this migration guide. We suggest that you read the +`corresponding +resources `__ +of the Qiskit Algorithms documentation instead. + +We can basically use the existing codes by replacing ``qiskit.algorithms`` +with ``qiskit_algorithms``. + + +``MinimumEigenOptimizer`` +------------------------- + +The former algorithms exist in +``qiskit.algorithms.minimum_eigensolvers``. +On the other hand, the new algorithms exist in +``qiskit_algorithms.minimum_eigensolvers`` and we can access them by +``qiskit_algorithms.*``. + +``MinimumEigenOptimizer`` of Qiskit Optimization can use +``qiskit_algorithms.SamplingMinimumEigensolver`` +interface of the new algorithms. Note that ``MinimumEigenOptimizer`` +cannot basically handle +``qiskit_algorithms.MinimumEigensolver`` of the new +algorithms. But there is an exception. ``MinimumEigenOptimizer`` can +handle ``qiskit_algorithms.NumPyMinimumEigensolver`` +because ``qiskit_algorithms.NumPyMinimumEigensolver`` has +an extension that allows users to access the eigen states. + +The following is the corresponding table. + +.. csv-table:: + :header: Former algorithm, New algorithm + + ``qiskit.algorithms.minimum_eigensolvers.SamplingMinimumEigensolver``, ``qiskit_algorithms.SamplingMinimumEigensolver`` + ``qiskit.algorithms.minimum_eigensolver.NumPyMinimumEigensolver``, ``qiskit_algorithms.NumPyMinimumEigensolver`` + ``qiskit.algorithms.minimum_eigensolvers.QAOA``, ``qiskit_algorithms.QAOA`` + ``qiskit.algorithms.minimum_eigensolvers.SamplingVQE``, ``qiskit_algorithms.SamplingVQE`` + + + +NumPyMinimumEigensolver +~~~~~~~~~~~~~~~~~~~~~~~ + +Previously + +.. code:: python + + from qiskit.algorithms.minimum_eigensolvers import NumPyMinimumEigensolver + + from qiskit_optimization.algorithms import MinimumEigenOptimizer + + mes = NumPyMinimumEigensolver() + meo = MinimumEigenOptimizer(min_eigen_solver=mes) + result = meo.solve(problem) + print(result) + + +New + +.. code:: python + + from qiskit_algorithms import NumPyMinimumEigensolver + + from qiskit_optimization.algorithms import MinimumEigenOptimizer + + mes = NumPyMinimumEigensolver() + meo = MinimumEigenOptimizer(min_eigen_solver=mes) + result = meo.solve(problem) + print(result) + + + +QAOA +~~~~ + +Previously + +.. code:: python + + from qiskit.algorithms.minimum_eigensolvers import QAOA + from qiskit.algorithms.optimizers import COBYLA + from qiskit.primitives import Sampler + + from qiskit_optimization.algorithms import MinimumEigenOptimizer + + shots = 1000 + mes = QAOA(sampler=Sampler(), optimizer=COBYLA()) + meo = MinimumEigenOptimizer(min_eigen_solver=mes) + result = meo.solve(problem) + print(result) + + +New + +.. code:: python + + from qiskit_algorithms import QAOA + from qiskit_algorithms.optimizers import COBYLA + from qiskit.primitives import Sampler + + from qiskit_optimization.algorithms import MinimumEigenOptimizer + + shots = 1000 + mes = QAOA(sampler=Sampler(), optimizer=COBYLA()) + meo = MinimumEigenOptimizer(min_eigen_solver=mes) + result = meo.solve(problem) + print(result) + + + +SamplingVQE +~~~~~~~~~~~ + +Previously + +.. code:: python + + from qiskit.algorithms.minimum_eigensolvers import SamplingVQE + from qiskit.algorithms.optimizers import COBYLA + from qiskit.circuit.library import RealAmplitudes + from qiskit.primitives import Sampler + + from qiskit_optimization.algorithms import MinimumEigenOptimizer + + mes = SamplingVQE(sampler=Sampler(), ansatz=RealAmplitudes(), optimizer=COBYLA()) + meo = MinimumEigenOptimizer(min_eigen_solver=mes) + result = meo.solve(problem) + print(result) + + +New + +.. code:: python + + from qiskit_algorithms import SamplingVQE + from qiskit_algorithms.optimizers import COBYLA + from qiskit.circuit.library import RealAmplitudes + from qiskit.primitives import Sampler + + from qiskit_optimization.algorithms import MinimumEigenOptimizer + + mes = SamplingVQE(sampler=Sampler(), ansatz=RealAmplitudes(), optimizer=COBYLA()) + meo = MinimumEigenOptimizer(min_eigen_solver=mes) + result = meo.solve(problem) + print(result) + + + +``WarmStartQAOAOptimizer`` +-------------------------- + + +Previously + +.. code:: python + + from qiskit.algorithms.minimum_eigensolvers import QAOA + from qiskit.algorithms.optimizers import COBYLA + from qiskit.primitives import Sampler + + from qiskit_optimization.algorithms import WarmStartQAOAOptimizer, SlsqpOptimizer + + qaoa = QAOA(sampler=Sampler(), optimizer=COBYLA()) + optimizer = WarmStartQAOAOptimizer( + pre_solver=SlsqpOptimizer(), relax_for_pre_solver=True, qaoa=qaoa, epsilon=0.25 + ) + result = optimizer.solve(problem) + print(result) + + +New + +.. code:: python + + from qiskit_algorithms import QAOA + from qiskit_algorithms.optimizers import COBYLA + from qiskit.primitives import Sampler + + from qiskit_optimization.algorithms import WarmStartQAOAOptimizer, SlsqpOptimizer + + qaoa = QAOA(sampler=Sampler(), optimizer=COBYLA()) + optimizer = WarmStartQAOAOptimizer( + pre_solver=SlsqpOptimizer(), relax_for_pre_solver=True, qaoa=qaoa, epsilon=0.25 + ) + result = optimizer.solve(problem) + print(result) + + + +``GroverOptimizer`` +------------------- + + +Previously + +.. code:: python + + from qiskit.algorithms.optimizers import COBYLA + from qiskit.primitives import Sampler + + from qiskit_optimization.algorithms import GroverOptimizer + + optimizer = GroverOptimizer(num_value_qubits=3, num_iterations=3, sampler=Sampler()) + result = optimizer.solve(problem) + print(result) + + +New + +.. code:: python + + from qiskit_algorithms.optimizers import COBYLA + from qiskit.primitives import Sampler + + from qiskit_optimization.algorithms import GroverOptimizer + + optimizer = GroverOptimizer(num_value_qubits=3, num_iterations=3, sampler=Sampler()) + result = optimizer.solve(problem) + print(result) diff --git a/releasenotes/notes/0.6-prelude-2740977b31d22583.yaml b/releasenotes/notes/0.6-prelude-2740977b31d22583.yaml index 70e1a4d36..520960a5b 100644 --- a/releasenotes/notes/0.6-prelude-2740977b31d22583.yaml +++ b/releasenotes/notes/0.6-prelude-2740977b31d22583.yaml @@ -2,7 +2,7 @@ prelude: > Qiskit Optimization has been migrated to the `qiskit-community Github organization `_ to further emphasize that it is a community-driven project. - To reflect this change and because we are onboarding additional codeowners and maintainers, + To reflect this change and because we are on-boarding additional code owners and maintainers, with this version (0.6) we have decided to *remove all deprecated* code, regardless of the time of its deprecation. This ensures that the new members of the development team do not have a large bulk of legacy code to maintain. From 1b014c7e301136767c415907da31e06e073d8010 Mon Sep 17 00:00:00 2001 From: Takashi Imamichi Date: Sat, 11 Nov 2023 01:43:08 +0900 Subject: [PATCH 3/4] update --- .../notes/switch-to-qiskit-algorithms-b0af38fe547bf5b5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/switch-to-qiskit-algorithms-b0af38fe547bf5b5.yaml b/releasenotes/notes/switch-to-qiskit-algorithms-b0af38fe547bf5b5.yaml index cdc98e8f2..db49d77ba 100644 --- a/releasenotes/notes/switch-to-qiskit-algorithms-b0af38fe547bf5b5.yaml +++ b/releasenotes/notes/switch-to-qiskit-algorithms-b0af38fe547bf5b5.yaml @@ -1,6 +1,6 @@ --- prelude: > - Qiskit Optimization 0.6 switches from ``qiskit.algorithms`` of Qiskit Terra + Qiskit Optimization 0.6 switches from ``qiskit.algorithms`` of Qiskit to `Qiskit Algorithms `_. Qiskit Optimization 0.6 drops supports of the former algorithms based on ``qiskit.algorithms``, ``QuantumInstance``, and Opflow of Qiskit Terra. From 80a1e987a1fd80c3ee2ac4e8e8c2fff34c52dc57 Mon Sep 17 00:00:00 2001 From: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> Date: Fri, 10 Nov 2023 13:38:54 -0500 Subject: [PATCH 4/4] Update releasenotes/notes/switch-to-qiskit-algorithms-b0af38fe547bf5b5.yaml --- .../notes/switch-to-qiskit-algorithms-b0af38fe547bf5b5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/switch-to-qiskit-algorithms-b0af38fe547bf5b5.yaml b/releasenotes/notes/switch-to-qiskit-algorithms-b0af38fe547bf5b5.yaml index db49d77ba..9563778f4 100644 --- a/releasenotes/notes/switch-to-qiskit-algorithms-b0af38fe547bf5b5.yaml +++ b/releasenotes/notes/switch-to-qiskit-algorithms-b0af38fe547bf5b5.yaml @@ -3,7 +3,7 @@ prelude: > Qiskit Optimization 0.6 switches from ``qiskit.algorithms`` of Qiskit to `Qiskit Algorithms `_. Qiskit Optimization 0.6 drops supports of the former algorithms based on - ``qiskit.algorithms``, ``QuantumInstance``, and Opflow of Qiskit Terra. + ``qiskit.algorithms``, ``QuantumInstance``, and Opflow of Qiskit. upgrade: - |