qiskit-optimization
qiskit-optimization copied to clipboard
[WIP] Remove qiskit-algorithms dependency
Summary
WIP. This PR removes qiskit-algorithms dependency based on #639. After #639 is merged, this PR needs to be rebased onto main branch.
TODO
- [x] merge #639 and rebase
- [x] add ignore words to pass spell check
- [ ] update tutorials
Details and comments
In looking at #662 and doing a quick search on this repo I see that tutorial12 ie 12_quantum_random_access_optimizer.ipynb in line[13] when viewing it here has the following which referred to Qiskit Algorithms - but the url is not where Algorithms docs are published. But given the class has been moved (copied) here the reference needs to be local now.
MinimumEigensolverResult: This object contains the results of running the minimum eigen optimizer such as the VQE on the relaxed problem. It provides information about the eigenvalue, and other relevant details. You can refer to the Qiskit Algorithms documentation for a comprehensive explanation of the entries within this object.
The tutorial test currently fails on the stable branch due to its dependency on qiskit-algorithms. Removing this dependency constitutes a breaking change. Supporting multiple versions of classes like SamplingVQE - which exist in both qiskit-algorithms and qiskit-optimization (this PR) - adds significant complexity. Given this, I propose we allow the breaking change and proceed with removing qiskit-algorithms. If this approach is acceptable, I can move forward with updating the codebase to support Qiskit 2.0.
I managed to pass tutorial test on stable branch by installing qiskit-algorithms only for the test. I fixed some compatibility issues though the tutorial tests too. It has finally passed all tests!
#634 had already brought over quite a bit from qiskit algorithms - from what I can see here this has added VQE and Grover to that. I see #634 has a bit of a release note - as does this in terms of an upgrade section. I wonder for an end use if it should mention VQE and Grover and perhaps give an example of switching some code fragment over from algorithms to optimization so its clear. The list of modules ported was already done by #634 right - though I guess the release notes will be merged as such so together maybe its fine. This PR added amplitude_amplifiers module (ie Grover) which I do not see listed.
Does the code still work with qiskit-algorithms? I imagine it does, at least for now since the interfaces, like minimum eigensolver ar compatible still with their signature - so unless there is some specific type check somewhere, which would break things, I guess the user has a migration path such that their code should still work but I imagine the recommendation would be to switch to whats here now instead.
This is more a CI related question seeing Win and Mac max levels are not 3.13. I believe that is such that it still tests with CPlex - which is also done with 3.9 and in fact is not even the latest Cplex. Wondering if it would be better to have the max level at the max level of Python, i.e. 3.13 and leave it just testing the Cplex on the lower bound. I imagine that the tutorials need cplex too hence the 3.12 there. Given Cplex has not been updated since end last year I wonder about it going forwards. Anyway any changes to CI could be done of wanted in another PR - its been a while and I was just having to recall/figure again why 3.13 was not more used in CI.
Thank you for your information about #634. We should coordinate reno when release 0.7.0.
Yes, CI tests with tutorials on stable branch, which uses qiskit-algorithms. I fixed some compatibility issues though the tests.
You are correct. We cannot use Python 3.13 because CPLEX does not support 3.13. The main reason we need CPLEX is QuadraticProgram.read_lp_file, which uses CPLEX under the hood. I plan to deprecate the method to use the latest Python versions for CI in the future (maybe 0.8.0 or later).
I also fixed coverage issue too. I removed tests with tweedledum because it has not been released since 2021 and Qiskit removed the related codes. https://github.com/Qiskit/qiskit/pull/13815
Pull Request Test Coverage Report for Build 16765681089
Details
- 352 of 386 (91.19%) changed or added relevant lines in 21 files are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage increased (+0.07%) to 92.191%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| qiskit_optimization/amplitude_amplifiers/amplitude_amplifier.py | 44 | 47 | 93.62% |
| qiskit_optimization/amplitude_amplifiers/grover.py | 102 | 109 | 93.58% |
| qiskit_optimization/amplitude_amplifiers/amplification_problem.py | 61 | 72 | 84.72% |
| qiskit_optimization/minimum_eigensolvers/vqe.py | 106 | 119 | 89.08% |
| <!-- | Total: | 352 | 386 |
| Totals | |
|---|---|
| Change from base Build 16765665414: | 0.07% |
| Covered Lines: | 6009 |
| Relevant Lines: | 6518 |
💛 - Coveralls
Thank you!