Skip to content
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

Remove runtime program, quantum instance, and opflow #542

Merged
merged 6 commits into from
Sep 1, 2023

Conversation

t-imamichi
Copy link
Collaborator

@t-imamichi t-imamichi commented Aug 30, 2023

Summary

This PR removes runtime clients, which have been already removed at IBM Quantum Platform, and QuantumInstance-based algorithms.

  • remove QuantumInstance-based legacy algorithms
  • remove VQEClient, QAOAClient, and VQERuntimeResult
  • remove Opflow
  • update tutorials
  • reno

Details and comments

It still uses opflow-based PauliSumOp somewhere for the compatibility. E.g., to_ising function to return PauliSumOp with the default option (option opflow=False returns SparsePauliOp). Should I remove them all as well?
→ Opflow is also removed.

@t-imamichi t-imamichi changed the title (WIP) Remove runtime program and quantum instance Remove runtime program and quantum instance Aug 30, 2023
@t-imamichi t-imamichi marked this pull request as ready for review August 30, 2023 14:28
@coveralls
Copy link

coveralls commented Aug 30, 2023

Pull Request Test Coverage Report for Build 6032830758

  • 23 of 27 (85.19%) changed or added relevant lines in 7 files are covered.
  • 7 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.6%) to 93.022%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit_optimization/algorithms/grover_optimizer.py 10 14 71.43%
Files with Coverage Reduction New Missed Lines %
qiskit_optimization/algorithms/optimization_algorithm.py 7 90.15%
Totals Coverage Status
Change from base Build 6021123767: 0.6%
Covered Lines: 4146
Relevant Lines: 4457

💛 - Coveralls

@woodsp-ibm
Copy link
Member

It still uses opflow-based PauliSumOp somewhere for the compatibility. E.g., to_ising function to return PauliSumOp with the default option (option opflow=False returns SparsePauliOp). Should I remove them all as well?

Yes, the intent is to cease use of deprecated function like that so supporting just SparsePauliOp is all that should be done.

In terms of other deprecated code in Opt, I did a quick search and this was all that came up for me. We should remove this too - in this case its time is up anyway (could have been removed last release)

@staticmethod
@deprecate_method(
"0.3.0", DeprecatedType.FUNCTION, "networkx.gnm_random_graph", "in NetworkX, directly"
)
def random_graph(num_nodes: int, num_edges: int, seed: Optional[int] = None) -> nx.Graph:
"""
Args:

@t-imamichi
Copy link
Collaborator Author

I removed opflow and updated tutorials and reno following Steve's feedback.

@t-imamichi t-imamichi changed the title Remove runtime program and quantum instance Remove runtime program, quantum instance, and opflow Aug 31, 2023
Comment on lines +142 to +143
if self._sampler is None:
raise ValueError("A sampler must be provided.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a comment on this. Given that a Sampler is now the only option with the removal of QI we could have defaulted the Sampler to the qiskit.primitives one if it was None in the constructor (and noted this for the sampler param there). That way the default value does not lead to an error - which seems strange. I get why it was done having to support both QI and Sampler. Since that is more of an improvement, and the GroverOptimizer was being looked at to be improved anyway, I think we can live with it like this, so as I said just a comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can make Sampler mandatory. But we need to change the argument order (need to move sampler first or second). Do you think whether we can change the argument order of GroverOptimizer.__init__?

Copy link
Member

@woodsp-ibm woodsp-ibm Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not talking about that much of a change. Leave it default to None and in the constructor do something like this

   if sampler is None:
      sampler = Sampler() # qiskit.primitives.Sampler

se we default it to the reference Sampler, and say we do this for the sampler param docstring. I think for the GroverOptimizer there had been some work done, not sure how far it went, to look at the issue raised some while back which was to have this use Grover rather than contain similar code. I think I would leave any more radical change until such a time as that might be done.

As I mentioned I am fine with leaving it like it is - its not that the GroverOptimizer is used much. Its not so great having an invalid default value as such but it is what it is due to this QI migration. The internal creating an instance of the default Sampler, if it were None, I thought more a simple improvement that might be done.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. I got it. I leave it as is. I will then work on #537 after merging this PR tomorrow.

Copy link
Member

@woodsp-ibm woodsp-ibm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me. I left a comment above but its just that a comment - I don't see it blocking this.

@mergify mergify bot merged commit 114cc11 into qiskit-community:main Sep 1, 2023
17 checks passed
@t-imamichi t-imamichi deleted the rm-qi-algos branch September 1, 2023 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants