-
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
Merged
Merged
Deprecate execute() #11044
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c8e6f3c
squash and change of base
1ucian0 f2c1c86
Update qiskit/execute_function.py
1ucian0 fb74576
test/visual/mpl/graph/test_graph_matplotlib_drawer.py
1ucian0 177677c
buggy bug
1ucian0 a4b152f
transpile
1ucian0 ef9c58d
Merge branch 'stable/0.46' into deprecate/execute/1
1ucian0 c9eaadd
Merge branch 'stable/0.46' into deprecate/execute/1
1ucian0 789d01a
examples
1ucian0 1bea14b
test/randomized
1ucian0 39535b9
hellinger_fidelity
1ucian0 05dd686
clean seed_transpiler
1ucian0 2fa2580
seed_transpiler in test_fake_backends
1ucian0 6ef382a
Operator
1ucian0 ee809ac
Fix pulse documentation
jakelishman 76ac20e
Fix overzealous deprecation skip
jakelishman a14084c
Remove other 'execute' uses in tests
jakelishman 9e36d18
Fix unused import
jakelishman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
releasenotes/notes/deprecate-execute-67a5c68b93722057.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
deprecations: | ||
- | | ||
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 | ||
use the :func:`~.transpile` function (with appropriate transpile | ||
options) followed by ``backend.run()`` (with appropriate run options). | ||
|
||
For example, instead of running:: | ||
|
||
from qiskit import execute | ||
job = execute(circuit, backend) | ||
|
||
you can run:: | ||
|
||
from qiskit import transpile | ||
new_circuit = transpile(circuit, backend) | ||
job = backend.run(new_circuit) | ||
|
||
Alternatively, the ``Sampler`` primitive is semantically equivalent to the | ||
deprecated :func:`~.execute_function.execute` function. The class | ||
:class:`.BackendSampler` is a generic wrapper for backends that do not support | ||
primitives: | ||
|
||
from qiskit.primitives import BackendSampler | ||
sampler = BackendSampler(backend) | ||
job = sampler.run(circuit) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ | |
|
||
from qiskit import BasicAer | ||
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit | ||
from qiskit import execute | ||
from qiskit.result import Result | ||
from qiskit.providers.basicaer import BasicAerError | ||
from qiskit.test import QiskitTestCase | ||
|
@@ -33,7 +32,7 @@ def setUp(self): | |
self._qc2 = QuantumCircuit(qr, cr, name="qc2") | ||
self._qc1.measure(qr[0], cr[0]) | ||
self.backend = BasicAer.get_backend("qasm_simulator") | ||
self._result1 = execute(self._qc1, self.backend).result() | ||
self._result1 = self.backend.run(self._qc1).result() | ||
Comment on lines
-36
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
def test_builtin_simulator_result_fields(self): | ||
"""Test components of a result from a local simulator.""" | ||
|
@@ -52,7 +51,7 @@ def test_basicaer_execute(self): | |
qc.cx(qubit_reg[0], qubit_reg[1]) | ||
qc.measure(qubit_reg, clbit_reg) | ||
|
||
job = execute(qc, self.backend) | ||
job = self.backend.run(qc) | ||
result = job.result() | ||
self.assertIsInstance(result, Result) | ||
|
||
|
@@ -66,7 +65,7 @@ def test_basicaer_execute_two(self): | |
qc.measure(qubit_reg, clbit_reg) | ||
qc_extra = QuantumCircuit(qubit_reg, clbit_reg, name="extra") | ||
qc_extra.measure(qubit_reg, clbit_reg) | ||
job = execute([qc, qc_extra], self.backend) | ||
job = self.backend.run([qc, qc_extra]) | ||
result = job.result() | ||
self.assertIsInstance(result, Result) | ||
|
||
|
@@ -76,7 +75,7 @@ def test_basicaer_num_qubits(self): | |
qc.x(0) | ||
qc.measure(0, 0) | ||
with self.assertRaises(BasicAerError): | ||
execute(qc, self.backend) | ||
self.backend.run(qc) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 whatexecute()
does (although imoexecute()
ortranspile()
followed bybackend.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