Skip to content

Commit

Permalink
Primitives (non runtime) changes for 1.0 (#812)
Browse files Browse the repository at this point in the history
Closes #1072 

Some helpful background: from Jessie: The goal of this document is for
people to test their quantum program (that calls primitives) locally,
before sending them to Qiskit Runtime to run on a real QPU.

Most of this page uses the statevector simulator, and there is an
equivalent for V2, better named as
[StatevectorEstimator](https://github.com/Qiskit/qiskit/blob/main/qiskit/primitives/statevector_estimator.py#L31)
and
[StatevectorSampler](https://github.com/Qiskit/qiskit/blob/main/qiskit/primitives/statevector_sampler.py#L52).

---------

Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
Co-authored-by: abbycross <across@us.ibm.com>
Co-authored-by: Elena Peña Tapia <epenatap@gmail.com>
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
  • Loading branch information
5 people authored Apr 19, 2024
1 parent 391d810 commit 731d7a7
Show file tree
Hide file tree
Showing 4 changed files with 402 additions and 330 deletions.
31 changes: 30 additions & 1 deletion docs/run/primitives-get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ service = QiskitRuntimeService(channel="ibm_cloud", channel_strategy="q-ctrl")
</Admonition>

<Admonition type="note">
These examples all use the primitives from Qiskit Runtime, but you could use the base primitives instead.
While this documentation uses the primitives from Qiskit Runtime, which allow you to use IBM&reg; backends, the primitives can be run on any provider by using the [backend primitives](#backend) instead. Additionally, you can use the *reference* primitives to run on a local statevector simulator. See [Exact simulation with Qiskit primitives](../verify/simulate-with-qiskit-primitives) for details.
</Admonition>

<span id="start-estimator"></span>
Expand Down Expand Up @@ -236,6 +236,35 @@ print(f" > Metadata: {result.metadata[0]}")
</TabItem>
</Tabs>

<span id="backend"></span>
## Get started with the backend primitives

The `Sampler` primitive can be run with any provider by using [`qiskit.primitives.BackendSampler`](../api/qiskit/qiskit.primitives.BackendSampler). Likewise, the `Estimator` primitive can be run with any provider using [`qiskit.primitives.BackendEstimator`](../api/qiskit/qiskit.primitives.BackendEstimator). Equivalent implementations in V2 are coming soon.

Some providers implement primitives natively (see [the Qiskit Ecosystem page](https://qiskit.github.io/ecosystem#providers) for more details).

### Example: BackendEstimator

```python
from qiskit.primitives import BackendEstimator
from <some_qiskit_provider> import QiskitProvider

provider = QiskitProvider()
backend = provider.get_backend('backend_name')
estimator = BackendEstimator(backend)
```

### Example: BackendSampler

```python
from qiskit.primitives import BackendSampler
from <some_qiskit_provider> import QiskitProvider

provider = QiskitProvider()
backend = provider.get_backend('backend_name')
sampler = BackendSampler(backend)
```

## Next steps

<Admonition type="tip" title="Recommendations">
Expand Down
Loading

0 comments on commit 731d7a7

Please sign in to comment.