Skip to content

Migration to qiskit 2.0 and integration testing #897

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

Open
Tracked by #54
ElePT opened this issue Mar 5, 2025 · 3 comments
Open
Tracked by #54

Migration to qiskit 2.0 and integration testing #897

ElePT opened this issue Mar 5, 2025 · 3 comments
Labels
dependencies 🔗 Involves external dependency libraries

Comments

@ElePT
Copy link
Collaborator

ElePT commented Mar 5, 2025

What should we add?

The Qiskit SDK CI includes an integration testing step of downstream packages through https://github.com/Qiskit/qiskit-neko, among which we include qiskit-machine-learning. This allows us to see that the removal of deprecated primitive V1 implementations (Qiskit/qiskit#13877) affects the qiskit-machine-learning -package, and that it will need an update to stay compatible with Qiskit 2.0.

You are free to decide if you want to migrate to 2.0 and when, but we recommend migrating for increased compatibility and support. On the qiskit-neko side,qiskit-machine-learning integration tests will be skipped until the package is updated. The first Qiskit 2.0 release candidate is planned for tomorrow, and the release is planned for ~March 20th.

Thank you for your effort maintaining Qiskit ML :) Let me know if you have any questions or need migration support.

@edoaltamura
Copy link
Collaborator

Thanks for keeping us in the loop @ElePT! We'd be very happy to give Neko a go when adding support for Qiskit 2.0. For us, this will likely be a 2-step process - first deprecating V1 primitives (and Qiskit v.0.x support), and then updating to 2.0 - and we'll get back to this at the right time. Really looking forward to seeing the 2.0 release out!

@edoaltamura edoaltamura added the dependencies 🔗 Involves external dependency libraries label Mar 11, 2025
@woodsp-ibm
Copy link
Member

woodsp-ibm commented Mar 14, 2025

As an FYI I would expect ML here to fail when/if Qiskit 2.0 is installed with it. I was just updating Algorithms to get CI running and you can see in the PR here qiskit-algorithms#221 that the tests against qiskit main fail to even start, as the class it uses/depends on has now been deleted.

 File "/home/runner/work/qiskit-algorithms/qiskit-algorithms/qiskit_algorithms/optimizers/__init__.py", line 139, in <module>
    from .qnspsa import QNSPSA
  File "/home/runner/work/qiskit-algorithms/qiskit-algorithms/qiskit_algorithms/optimizers/qnspsa.py", line 23, in <module>
    from qiskit.primitives import BaseSampler
ImportError: cannot import name 'BaseSampler' from 'qiskit.primitives' (/opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages/qiskit/primitives/__init__.py)

In algorithms I added a pin for qiskit < 2.0 so it will not install 2.0, when its released shortly, as its incompatible. Here you have support for V2 primitives and with V1 being deprecated it was already stated in the 0.8 release notes that From version 0.9, V1 primitives will be removed. To keep 0.8 running for new installs etc, ahead of 0.9 being released, you could release a last version with qiskit pinned < 2.0 so that installing ML does not pull in 2.0 but an earlier version to ensure it works and that the user does not have to do something manually to sort things.

If you wanted to try things with Qiskit 2.0 locally to see what happens there is an ReleaseCandidate2 that was just put out following on from RC1 earlier this week https://pypi.org/project/qiskit/2.0.0rc2/

@woodsp-ibm
Copy link
Member

Just as a note updating the code to V2.0 is gong to be more than primitives. In looking at the deprecation messages currently emitted there are others around operators and library circuits. eg

test_qnn_circuit.py:130: PendingDeprecationWarning: The class qiskit.circuit.library.n_local.efficient_su2.EfficientSU2 is pending deprecation as of qiskit 1.3. It will be marked deprecated in a future release, and then removed no earlier than 3 months after the release date. Use the function qiskit.circuit.library.efficient_su2 instead.

This seems to be similarly the case for ZFeatureMap, ZZFeatureMap, PauliFeatureMap, RealAmplitudes, EfficientSU2...


Also I see

/home/runner/work/qiskit-machine-learning/qiskit-machine-learning/test/algorithms/classifiers/test_vqc.py:79: DeprecationWarning: qiskit.providers.fake_provider.generic_backend_v2.GenericBackendV2.__init__()'s argument pulse_channels is deprecated as of Qiskit 1.3. It will be removed in Qiskit 2.0. The entire Qiskit Pulse package is being deprecated and this argument uses a dependency on the package.


And while this below is not Qiskit related as its among the captured deprecation warnings - that hopefully will all no longer exist after updating - I just note it here for completion

/home/runner/work/qiskit-machine-learning/qiskit-machine-learning/qiskit_machine_learning/neural_networks/neural_network.py:127: DeprecationWarning: array implementation doesn't accept a copy keyword, so passing copy=False failed. array must implement 'dtype' and 'copy' keyword arguments. To learn more, see the migration guide https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword


In changing the above Qiskit related code it seems that Qiskit 1.,3 would then become a minimum requirement (currently the requirements has >1.0, < 2.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies 🔗 Involves external dependency libraries
Projects
None yet
Development

No branches or pull requests

3 participants