-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Deprecate execute() #11044
Deprecate execute() #11044
Conversation
One or more of the the following people are requested to review this:
|
Qiskit's :func:`~.execute_function.execute` function is deprecated. | ||
This function served as a high-level wrapper around transpiling | ||
a circuit with some transpile options and running it on a backend | ||
with some run options. To do the same thing, you can explicitly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to call out the sampler here too? The BackendSampler
class is fairly straightforward mapping to what execute()
does (although imo execute()
or transpile()
followed by backend.run()
are much easier to work with).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an example in 0367d40
(A minor note: CI's likely to be busy today, so if we're able to try and keep the number of commits we submit to CI down by doing more testing locally, it'll help keep the rc1 release more to time.) |
f9c83b8
to
c8e6f3c
Compare
Co-authored-by: Matthew Treinish <[email protected]>
Pull Request Test Coverage Report for Build 6749790272
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, Luciano. A few more notes for consideration:
- in
examples/python
, there's still uses ofexecute
. I don't know if we still even want to keep that folder, but if so, we probably ought to change them to at least bebackend.run
/transpile
if notSampler
. test/randomized
still has a couple of uses ofexecute
- the docstring of
qiskit.quantum_info.analysis.distance.hellinger_fidelity
still usesexecute
in an example
I noticed there's a few places in the tests where execute
was replaced only with backend.run
(no transpile
), typically for BasicAer
backends. I suspect that's probably a fine change and won't affect anything, just pointing it out. There's a few of those changes that have left a spurious seed_transpiler
argument in backend.run
, though, which it looks like BasicAer just ignores. We should probably tidy those up.
self._result1 = execute(self._qc1, self.backend).result() | ||
self._result1 = self.backend.run(self._qc1).result() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I imagine it will matter here, but technically this is a behavioural change due to the missing transpile
. Same comment for most changes in the next two files.
backend = BasicAer.get_backend("unitary_simulator") | ||
simulated = execute(qc, backend).result().get_unitary(qc) | ||
simulated = backend.run(transpile(qc, backend)).result().get_unitary(qc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't mind just changing these into simulated = Operator(qc)
, but this is also fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 6ef382a
job = execute( | ||
self.circuit, | ||
backend, | ||
job = backend.run( | ||
transpile(self.circuit, backend), | ||
optimization_level=optimization_level, | ||
seed_simulator=42, | ||
seed_transpiler=42, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, and the other test in this file, set seed_transpiler
which ideally needs moving into the transpile
call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed. Done in 2fa2580
Good catches!
Fixed in 39535b9
Fixed in 1bea14b
Fixed in 39535b9
Yes. It was intentional for the cases where it was possible, as a way to minimize the changes.
done in 05dd686 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed up a couple more commits just to squash a couple more places I spotted, or places where we using a warning skip when Operator(qc)
was just as easy.
I found one place that was skipping warnings for bind_parameters
with a module='test\.python\.circuit\.test_parameters'
(or something) that was causing an execute
to get missed, but that's actually a good think - it shows the stacklevel
was set correctly, otherwise it wouldn't have been skipped by that! (I fixed the skip by adding a regex match for messages mentioning the intended target.)
There's a couple of places that still use execute
in tests along with other deprecated or dead code that's being tidied up elsewhere, so I've just left them. Let's get this into the merge queue.
Summary
The execute() function is as old as the SDK and it was always a high-level combinant function to say "here, a circuit, do your thing". That is exactly what Qiskit Primitives are about. Time to deprecated it.
Closes #7892
Closes #7640