|
7 | 7 | "source": [ |
8 | 8 | "---\n", |
9 | 9 | "title: Inputs and outputs\n", |
10 | | - "description: Understand the inputs and outputs to the Executor primitive\n", |
| 10 | + "description: Understand the inputs and outputs to the Executor primitive.\n", |
11 | 11 | "---\n", |
12 | 12 | "\n", |
13 | 13 | "\n", |
|
45 | 45 | }, |
46 | 46 | { |
47 | 47 | "cell_type": "markdown", |
48 | | - "id": "6962c44c-da86-45ac-a70f-bd4ceb2c262b", |
49 | 48 | "metadata": {}, |
50 | 49 | "source": [ |
51 | | - "This page gives an overview of the inputs and outputs of the Qiskit Runtime primitives that execute workloads on IBM Quantum® compute resources. These primitives provide you with the ability to efficiently define vectorized workloads by using a data structure known as a **Primitive Unified Bloc (PUB)**. These PUBs are the fundamental unit of work a QPU needs to execute these workloads. They are used as inputs to the [`run()`](/docs/api/qiskit-ibm-runtime/estimator-v2#run) method for the Sampler and Estimator primitives, which execute the defined workload as a job. Then, after the job has completed, the results are returned in a format that is dependent on both the PUBs used as well as the runtime options specified from the Sampler or Estimator primitives." |
| 50 | + "The inputs and output of the Executor primitive are very different from those of the Sampler and Estimator primitives. As part of the [directed execution model,](/docs/guides/directed-execution-model) the Executor primitive helps provide more flexibility when customizing your error mitigation workflow. This primitive takes a `QuantumProgram` as input, and outputs a Qiskit Runtime job, which is then run on an IBM quantum computer." |
52 | 51 | ] |
53 | 52 | }, |
54 | 53 | { |
55 | 54 | "cell_type": "markdown", |
56 | 55 | "metadata": {}, |
57 | 56 | "source": [ |
58 | | - "The inputs to the Executor: Quantum Programs\n", |
59 | | - "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", |
| 57 | + "## Quantum programs\n", |
60 | 58 | "\n", |
61 | | - "A :class:`~.QuantumProgram` is an iterable of\n", |
62 | | - ":class:`~.qiskit_ibm_runtime.quantum_program.QuantumProgramItem`\\s. Each of these items represents a\n", |
63 | | - "different task for the :class:`~.Executor` to perform. Typically, each item owns:\n", |
| 59 | + "The input to Executor primitives is a [`QuantumProgram`](https://qiskit.github.io/qiskit-ibm-runtime/stubs/qiskit_ibm_runtime.quantum_program.QuantumProgram.html#qiskit_ibm_runtime.quantum_program.QuantumProgram), which is an iterable of a \n", |
| 60 | + "`qiskit_ibm_runtime.quantum_program.QuantumProgramItem`. Each of these items represents a\n", |
| 61 | + "different task for the Executor to perform. Typically, each item owns:\n", |
64 | 62 | "\n", |
65 | | - "* a :class:`~qiskit.circuit.QuantumCircuit` with static, non-parametrized gates;\n", |
66 | | - "* or a parametrized :class:`~qiskit.circuit.QuantumCircuit`, together with an array of parameter values;\n", |
67 | | - "* or a parametrized :class:`~qiskit.circuit.QuantumCircuit`, together with a\n", |
68 | | - " :class:`~samplomatic.samplex.Samplex` to generate randomize arrays of parameter values.\n", |
| 63 | + "* a `qiskit.circuit.QuantumCircuit` with static, non-parametrized gates;\n", |
| 64 | + "* or a parametrized `qiskit.circuit.QuantumCircuit`, together with an array of parameter values;\n", |
| 65 | + "* or a parametrized `qiskit.circuit.QuantumCircuit`, together with a\n", |
| 66 | + " `samplomatic.samplex.Samplex` to generate randomize arrays of parameter values.\n", |
69 | 67 | "\n", |
70 | | - "Let us take a closer look at each of these items and how to add them to a :class:`~.QuantumProgram`\\.\n", |
| 68 | + "Let us take a closer look at each of these items and how to add them to a `QuantumProgram`\\.\n", |
71 | 69 | "\n", |
72 | | - "In the cell below, we initialize a :class:`~.QuantumProgram` and specify that we wish to perform ``1024``\n", |
| 70 | + "In the cell below, we initialize a `QuantumProgram` and specify that we wish to perform ``1024``\n", |
73 | 71 | "shots for every configuration of each item in the program. Next, we append a version of our target circuit with set parameters,\n", |
74 | 72 | "transpiled according to the backend's ISA.\n", |
75 | 73 | "\n", |
|
102 | 100 | " # Append the circuit to the program\n", |
103 | 101 | " program.append_circuit_item(isa_circuit)\n", |
104 | 102 | "\n", |
105 | | - "We proceed to append a second item that contains a parametrized :class:`~qiskit.circuit.QuantumCircuit`\n", |
| 103 | + "We proceed to append a second item that contains a parametrized `qiskit.circuit.QuantumCircuit`\n", |
106 | 104 | "and an array containing ``10`` sets of parameter values. This amounts to a circuit task requiring a total\n", |
107 | 105 | "of ``10240`` shots (namely ``1024`` per set of parameter values).\n", |
108 | 106 | "\n", |
|
135 | 133 | " circuit_arguments=np.random.rand(10, 3), # 10 sets of parameter values\n", |
136 | 134 | " )\n", |
137 | 135 | "\n", |
138 | | - "Finally, in the next cell we append a parametrized :class:`~qiskit.circuit.QuantumCircuit` and a\n", |
139 | | - ":class:`~samplomatic.samplex.Samplex`, which is responsible for generating randomized sets of\n", |
140 | | - "parameters for the given circuit. As part of the :class:`~samplomatic.samplex.Samplex` arguments,\n", |
| 136 | + "Finally, in the next cell we append a parametrized `qiskit.circuit.QuantumCircuit` and a\n", |
| 137 | + "`samplomatic.samplex.Samplex`, which is responsible for generating randomized sets of\n", |
| 138 | + "parameters for the given circuit. As part of the `samplomatic.samplex.Samplex` arguments,\n", |
141 | 139 | "we provide ``10`` sets of parameters for the parametric gates in the original circuit.\n", |
142 | 140 | "Additionally, we use the ``shape`` request argument to request an extension of the implicit shape\n", |
143 | | - "defined by the :class:`~samplomatic.samplex.Samplex` arguments. In particular, by setting ``shape``\n", |
| 141 | + "defined by the `samplomatic.samplex.Samplex` arguments. In particular, by setting ``shape``\n", |
144 | 142 | "to ``(2, 14, 10)`` we request to randomize each of the ``10`` sets of parameters ``28`` times, and\n", |
145 | 143 | "to arrange the randomized parameter sets in an array of be arranged in an array of shape\n", |
146 | 144 | "``(2, 14, 10)``.\n", |
147 | 145 | "\n", |
148 | | - " We refer the reader to :mod:`~samplomatic` and its documentation for more details on the\n", |
149 | | - " :class:`~samplomatic.samplex.Samplex` and its arguments.\n", |
| 146 | + " We refer the reader to :mod`~samplomatic` and its documentation for more details on the\n", |
| 147 | + " `samplomatic.samplex.Samplex` and its arguments.\n", |
150 | 148 | "\n", |
151 | 149 | ".. code-block:: python\n", |
152 | 150 | "\n", |
|
190 | 188 | " shape=(2, 14, 10),\n", |
191 | 189 | " )\n", |
192 | 190 | "\n", |
193 | | - "Now that we have populated our :class:`~.QuantumProgram`, we can proceed with execution." |
| 191 | + "Now that we have populated our `QuantumProgram`, we can proceed with execution." |
194 | 192 | ] |
195 | 193 | } |
196 | 194 | ], |
|
0 commit comments