initial changes

This commit is contained in:
Rebecca Dimock 2024-09-23 14:39:21 -05:00
parent eb56a0f03b
commit 62e7010b59
2 changed files with 25 additions and 20 deletions

View File

@ -15,6 +15,7 @@
"id": "04b9204f-f058-433b-89f9-05df14645e27",
"metadata": {},
"source": [
"<span id=\"pubs\"></span>\n",
"## Overview of PUBs\n",
"\n",
"When invoking a primitive's [`run()`](../api/qiskit-ibm-runtime/qiskit_ibm_runtime.EstimatorV2#run) method, the main argument that is required is a `list` of one or more tuples -- one for each circuit being executed by the primitive. Each of these tuples is considered a PUB, and the required elements of each tuple in the list depends on the the primitive used. The data provided to these tuples can also be arranged in a variety of shapes to provide flexibility in a workload through broadcasting -- the rules of which are described in a [following section](#broadcasting-rules).\n",

View File

@ -21,38 +21,42 @@ As we move toward larger QPUs (quantum processing units) and more complex workfl
qubit signals to viewing quantum devices as systems that perform tasks we need.
The two most common tasks quantum computers are used for are sampling quantum states and calculating expectation values.
These tasks motivated the design of the Qiskit primitives: Sampler and Estimator.
These tasks motivated the design of the Qiskit primitives: **Estimator** and **Sampler**.
- [Estimator](#estimator) computes expectation values of observables with respect to states prepared by quantum circuits.
- [Sampler](#sampler) samples the output register from execution of quantum circuits.
In short, the computational model introduced by the Qiskit primitives moves quantum programming one step closer
to where classical programming is today, where the focus is less on the hardware details and more on the results
you are trying to achieve.
## Implementation of Qiskit primitives
The Qiskit primitives are defined by open-source primitive base-classes, from
which different providers can derive their own Sampler and Estimator implementations. Among the implementations
using Qiskit, you can find reference primitive implementations for local simulation in the `qiskit.primitives` module.
Providers like Qiskit Runtime enable access to appropriate QPUs through native implementations of
their own primitives.
## Benefits of Qiskit primitives
For Qiskit users, primitives let you write quantum code for a specific QPU without having to explicitly
manage every detail. Also, because of the additional layer of abstraction, you might be able to more easily
access advanced hardware capabilities of a given provider. For example, with Qiskit Runtime primitives,
you can leverage the latest advancements in error mitigation and suppression by toggling options such as `resilience_level`, rather than building your own implementation of these techniques.
you can leverage the latest advancements in error mitigation and suppression by toggling options such as [`resilience_level`,](/api/qiskit-ibm-runtime/qiskit_ibm_runtime.options.EstimatorOptions#resilience_level) rather than building your own implementation of these techniques.
For hardware providers, implementing primitives natively means you can provide your users with a more “out-of-the-box”
way to access your hardware features. It is therefore easier for your users to benefit from your hardware's
best capabilities.
## Implementation of Qiskit primitives
The Qiskit primitives are defined by open-source primitive base-classes, from
which different providers can derive their own Sampler and Estimator implementations. Among the implementations
using Qiskit, you can find reference primitive implementations for local simulation in the [`qiskit.primitives`](/api/qiskit/primitives) module.
Providers like [Qiskit Runtime](/api/qiskit-ibm-runtime/runtime_service) enable access to appropriate QPUs through native implementations of
their own primitives.
<span id="estimator"></span>
## Estimator
Estimator computes expectation values of observables with respect to states prepared by quantum circuits. The circuits can be parametrized, as long as the parameter values are also provided as input to the primitive.
The input is an array of PUBs. Each PUB is in the format (`<single circuit>`, `<one or more observables>`, `<optional one or more parameter values>`, `<optional precision>`), where the optional `parameter values` can be a list or a single parameter. Different Estimator implementations support various configuration options.
The input is an array of [PUBs.](/guides/primitive-input-output#pubs) Each PUB is in the format (`<single circuit>`, `<one or more observables>`, `<optional one or more parameter values>`, `<optional precision>`), where the optional `parameter values` can be a list or a single parameter. Different Estimator implementations support various configuration options. If the input contains measurements, they are ignored.
The output is a `PubResult` that contains the computed expectation values per pair, and their standard errors, in `PubResult` form. Each `PubResult` contains both data and metadata.
The output is a [`PubResult`](/api/qiskit/qiskit.primitives.PubResult#pubresult) that contains the computed expectation values per pair, and their standard errors, in `PubResult` form. Each `PubResult` contains both data and metadata.
Estimator combines elements from observables and parameter values by following NumPy broadcasting rules as described in the [Primitive inputs and outputs](primitive-input-output#broadcasting-rules) topic.
@ -68,9 +72,9 @@ estimator.run([(circuit1, observable1, param_values1),(circuit2, observable2, pa
Sampler's core task is sampling the output register from execution of quantum circuits. The input circuits can be parametrized, as long as the parameter values are also provided as input to the primitive.
The input is one or more PUBs, in the format (`<single circuit>`, `<optional one or more parameter values>`, `<optional shots>`), where there can be multiple `parameter values` items, and each item can be either an array or a single parameter, depending on the chosen circuit.
The input is one or more [PUBs,](/guides/primitive-input-output#pubs) in the format (`<single circuit>`, `<optional one or more parameter values>`, `<optional shots>`), where there can be multiple `parameter values` items, and each item can be either an array or a single parameter, depending on the chosen circuit. Additionally, the input must contain measurements.
The output is counts or per-shot measurements, as `PubResult` objects, without weights. The result class, however, has methods to return weighted samples, such as counts. See [Primitive inputs and outputs](primitive-input-output#broadcasting-rules) for full details.
The output is counts or per-shot measurements, as [`PubResult`](/api/qiskit/qiskit.primitives.PubResult#pubresult) objects, without weights. The result class, however, has methods to return weighted samples, such as counts. See [Primitive inputs and outputs](primitive-input-output#broadcasting-rules) for full details.
Example:
@ -83,19 +87,19 @@ sampler.run([
## How to use Qiskit primitives
The `qiskit.primitives` module enables the development of primitive-style quantum programs and was specifically
The [`qiskit.primitives`](/api/qiskit/primitives) module enables the development of primitive-style quantum programs and was specifically
designed to simplify switching between different types of quantum compute resources. The module provides three separate classes
for each primitive type:
1. `StatevectorSampler` and `StatevectorEstimator`
1. [`StatevectorEstimator`](/api/qiskit/qiskit.primitives.StatevectorEstimator) and [`StatevectorSampler`](/api/qiskit/qiskit.primitives.StatevectorSampler#statevectorsampler)
These classes are reference implementations of both primitives and use the simulator built in to Qiskit. They leverage the Qiskit `quantum_info` module in the background, producing results based on ideal statevector simulations.
These classes are reference implementations of both primitives and use the simulator built in to Qiskit. They leverage the Qiskit [`quantum_info`](/api/qiskit/quantum_info#quantum-information) module in the background, producing results based on ideal statevector simulations.
2. `BaseSampler` and `BaseEstimator`
2. [`BaseEstimatorV2`](/api/qiskit/qiskit.primitives.BaseEstimatorV2) and [`BaseSamplerV2`](/api/qiskit/qiskit.primitives.BaseSamplerV2)
These are abstract base classes that define a common interface for implementing primitives. All other classes in the `qiskit.primitives` module inherit from these base classes, and developers should use these if they are interested in developing their own primitives-based execution model for a specific provider. These classes may also be useful for those who want to do highly customized processing and find the existing primitives implementations too simple for their needs.
These are abstract base classes that define a common interface for implementing primitives. All other classes in the [`qiskit.primitives`](/api/qiskit/primitives) module inherit from these base classes, and developers should use these if they are interested in developing their own primitives-based execution model for a specific provider. These classes may also be useful for those who want to do highly customized processing and find the existing primitives implementations too simple for their needs.
3. `BackendSampler` and `BackendEstimator`
3. [`BackendEstimatorV2`](/api/qiskit/qiskit.primitives.BackendEstimatorV2) and [`BackendSamplerV2`](/api/qiskit/qiskit.primitives.BackendSamplerV2)
If a provider does not support primitives natively, you can use these classes to “wrap” any quantum computing resource into a primitive. Users can write primitive-style code for providers that dont yet have a primitives-based interface. These classes can be used just like the regular Sampler and Estimator, except they should be initialized with an additional `backend` argument for selecting which quantum computer to run on.