Skip to content

Commit 8ed78c3

Browse files
committed
Start adding executor input
1 parent 4fda3e1 commit 8ed78c3

File tree

5 files changed

+180
-826
lines changed

5 files changed

+180
-826
lines changed

docs/guides/directed-execution-model.mdx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Directed execution model (beta)
2+
title: Directed execution model
33
description: Use this composable, explicit execution model with your utility-scale experiments to fine-tune error mitigation and other techniques.
44

55
---
@@ -26,7 +26,7 @@ To apply error mitigation to a circuit under the framework, your workflow will t
2626

2727
3. Build the template circuit and samplex from the boxed circuit.
2828

29-
4. Run the template circuit and samplex with the [Executor](#executor-primitive) primitive, which will generate and execute the circuit variants as instructed.
29+
4. Run the template circuit and samplex with the [Executor](#executor) primitive, which will generate and execute the circuit variants as instructed.
3030

3131
5. Post-process execution results. For example, you can apply post-selection, or extrapolate mitigated expectation values from the execution results.
3232

@@ -41,21 +41,17 @@ The following tools can be used together to implement an error mitigation techni
4141

4242
![Example of using boxes and twirling annotations](/docs/images/guides/directed-execution-model/execution-model.avif)
4343

44-
A circuit with annotated boxes can then be used to generate a *template circuit* and a *samplex*. The output template circuit is a parameterized circuit that will be executed without further alteration (other than having different parameter values assigned to it). The samplex, which is the core type of the Samplomatic library, represents a parametric probability distribution over the parameters of the template circuit and other array-valued fields. These fields can be used to post-process data collected from executing the bound template circuit. In other words, the template circuit and samplex pair tells the Executor primitive (described below) exactly what parameters to generate and what bound circuits to run. Because these two constructs are created on the client side, you can do local inspection and sampling to verify the outputs prior to sending it for hardware execution.
44+
A circuit with annotated boxes can then be used to generate a *template circuit* and a *samplex*. The output template circuit is a parameterized circuit that will be executed without further alteration (other than having different parameter values assigned to it). The samplex, which is the core type of the Samplomatic library, represents a parametric probability distribution over the parameters of the template circuit and other array-valued fields. These fields can be used to post-process data collected from executing the bound template circuit. In other words, the template circuit and samplex pair tells the [Executor primitive](#executor) exactly what parameters to generate and what bound circuits to run. Because these two constructs are created on the client side, you can do local inspection and sampling to verify the outputs prior to sending it for hardware execution.
4545

4646
To simplify the process of generating annotated boxes, the Samplomatic library also provides transpiler passes that automatically group circuit instructions into annotated boxes, based on the strategies you provide.
4747

4848
To learn more about Samplomatic, visit the [guides](https://qiskit.github.io/samplomatic/guides/index.html) and [API reference](https://qiskit.github.io/samplomatic/) documentation. Feel free to submit feedback and report bugs in its [GitHub](https://github.com/Qiskit/samplomatic) repository.
4949

50+
<span id="executor"></span>
5051
### Executor primitive
5152

5253
Executor is a new Qiskit Runtime primitive that takes the template circuit and samplex pair as the input, generates and binds parameter values according to the samplex, executes the bound circuits on the hardware, and returns the execution results and metadata. It follows the directives of the input pair and does not make any implicit decisions for you, so that the process is transparent yet performant.
5354

54-
To access `Executor`, install the `executor_preview` branch from `qiskit-ibm-runtime`:
55-
56-
```bash
57-
pip install -U git+https://github.com/Qiskit/qiskit-ibm-runtime.git@executor_preview
58-
```
5955
The inputs and output of the Executor primitive are very different from those of Sampler and Estimator. Refer to the [Executor API reference](https://qiskit.github.io/qiskit-ibm-runtime/stubs/qiskit_ibm_runtime.Executor.html) for more information. In addition, the [Executor quickstart guide](https://qiskit.github.io/qiskit-ibm-runtime/guides/executor_basic.html) provides an overview and code examples.
6056

6157
### NoiseLearnerV3

docs/guides/estimator-examples.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"source": [
88
"---\n",
99
"title: Examples\n",
10-
"description: Practical examples of using Estimator primitives in Qiskit Runtime.\n",
10+
"description: Practical examples of using Estimator primitive in Qiskit Runtime.\n",
1111
"---\n",
1212
"\n",
1313
"\n",
14-
"# Primitives examples"
14+
"# Estimator examples"
1515
]
1616
},
1717
{

docs/guides/executor-examples.ipynb

Lines changed: 35 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"metadata": {},
77
"source": [
88
"---\n",
9-
"title: Primitives examples\n",
10-
"description: Practical examples of using primitives in Qiskit Runtime.\n",
9+
"title: Examples\n",
10+
"description: Practical examples of using the Executor primitve in Qiskit Runtime.\n",
1111
"---\n",
1212
"\n",
1313
"\n",
14-
"# Primitives examples"
14+
"# Executor examples"
1515
]
1616
},
1717
{
@@ -58,64 +58,49 @@
5858
"id": "bae32e60",
5959
"metadata": {},
6060
"source": [
61-
"The examples in this section illustrate some common ways to use primitives. Before running these examples, follow the instructions in [Install and set up.](install-qiskit)\n",
62-
"\n",
63-
"<Admonition type=\"note\">\n",
64-
" These examples all use the primitives from Qiskit Runtime, but you could use the base primitives instead.\n",
65-
"</Admonition>\n",
66-
"\n",
67-
"## Estimator examples\n",
68-
"\n",
69-
"Efficiently calculate and interpret expectation values of the quantum operators required for many algorithms with Estimator. Explore uses in molecular modeling, machine learning, and complex optimization problems.\n",
61+
"The examples in this section illustrate some common ways to use the Executor primitive. Before running these examples, follow the instructions in [Install and set up.](install-qiskit)\n",
7062
"\n",
7163
"### Run a single experiment\n",
7264
"\n",
73-
"Use Estimator to determine the expectation value of a single circuit-observable pair."
65+
"Consider a circuit that generates a three-qubit GHZ state, rotates\n",
66+
"the qubits around the Pauli-Z axis, and measures the qubits in the computational basis. We show how\n",
67+
"to add this circuit to a `QuantumProgram`, optionally randomizing its content with twirling\n",
68+
"gates, and execute the program by using the `Executor` class."
7469
]
7570
},
7671
{
7772
"cell_type": "code",
78-
"execution_count": 1,
79-
"id": "24573866-7cf2-40e1-b61c-a2bdcecb759b",
73+
"execution_count": null,
8074
"metadata": {},
81-
"outputs": [
82-
{
83-
"name": "stdout",
84-
"output_type": "stream",
85-
"text": [
86-
" > Expectation value: -0.13582342954159593\n",
87-
" > Metadata: {'shots': 4096, 'target_precision': 0.015625, 'circuit_metadata': {}, 'resilience': {}, 'num_randomizations': 32}\n"
88-
]
89-
}
90-
],
75+
"outputs": [],
9176
"source": [
92-
"import numpy as np\n",
93-
"from qiskit.circuit.library import iqp\n",
94-
"from qiskit.transpiler import generate_preset_pass_manager\n",
95-
"from qiskit.quantum_info import SparsePauliOp, random_hermitian\n",
96-
"from qiskit_ibm_runtime import QiskitRuntimeService, EstimatorV2 as Estimator\n",
97-
"\n",
98-
"n_qubits = 50\n",
77+
"from qiskit.circuit import Parameter, QuantumCircuit\n",
78+
"from qiskit_ibm_runtime import QiskitRuntimeService, Executor\n",
79+
"\n",
80+
"# Generate the circuit\n",
81+
"circuit = QuantumCircuit(3)\n",
82+
"circuit.h(0)\n",
83+
"circuit.h(1)\n",
84+
"circuit.cz(0, 1)\n",
85+
"circuit.h(1)\n",
86+
"circuit.h(2)\n",
87+
"circuit.cz(1, 2)\n",
88+
"circuit.h(2)\n",
89+
"circuit.rz(Parameter(\"theta\"), 0)\n",
90+
"circuit.rz(Parameter(\"phi\"), 1)\n",
91+
"circuit.rz(Parameter(\"lam\"), 2)\n",
92+
"circuit.measure_all()\n",
9993
"\n",
94+
"# Initialize the service and choose a backend\n",
10095
"service = QiskitRuntimeService()\n",
101-
"backend = service.least_busy(\n",
102-
" operational=True, simulator=False, min_num_qubits=n_qubits\n",
103-
")\n",
104-
"\n",
105-
"mat = np.real(random_hermitian(n_qubits, seed=1234))\n",
106-
"circuit = iqp(mat)\n",
107-
"observable = SparsePauliOp(\"Z\" * 50)\n",
108-
"\n",
109-
"pm = generate_preset_pass_manager(backend=backend, optimization_level=1)\n",
110-
"isa_circuit = pm.run(circuit)\n",
111-
"isa_observable = observable.apply_layout(isa_circuit.layout)\n",
112-
"\n",
113-
"estimator = Estimator(mode=backend)\n",
114-
"job = estimator.run([(isa_circuit, isa_observable)])\n",
115-
"result = job.result()\n",
116-
"\n",
117-
"print(f\" > Expectation value: {result[0].data.evs}\")\n",
118-
"print(f\" > Metadata: {result[0].metadata}\")"
96+
"backend = service.least_busy(operational=True, simulator=False)"
97+
]
98+
},
99+
{
100+
"cell_type": "markdown",
101+
"metadata": {},
102+
"source": [
103+
"The inputs to the `Executor` are `QuantumProgram`s. For full details, see [Executor input and output.](/docs/guides/executor-input-output)"
119104
]
120105
},
121106
{

0 commit comments

Comments
 (0)