Skip to content

Commit

Permalink
REgen dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Arellano committed Mar 6, 2024
1 parent 49253db commit 7a2ff9e
Show file tree
Hide file tree
Showing 138 changed files with 1,142 additions and 658 deletions.
2 changes: 1 addition & 1 deletion docs/api/qiskit-ibm-runtime/dev/_package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "qiskit-ibm-runtime",
"version": "0.20.1-dev"
"version": "0.21.1-dev"
}
48 changes: 40 additions & 8 deletions docs/api/qiskit-ibm-runtime/dev/_toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
"title": "Overview",
"url": "/api/qiskit-ibm-runtime/dev/runtime_service"
},
{
"title": "Estimator",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.Estimator"
},
{
"title": "IBMBackend",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.IBMBackend"
Expand All @@ -36,10 +32,6 @@
"title": "RuntimeOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.RuntimeOptions"
},
{
"title": "Sampler",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.Sampler"
},
{
"title": "Session",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.Session"
Expand Down Expand Up @@ -466,29 +458,69 @@
"title": "Overview",
"url": "/api/qiskit-ibm-runtime/dev/options"
},
{
"title": "DynamicalDecouplingOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.DynamicalDecouplingOptions"
},
{
"title": "EnvironmentOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.EnvironmentOptions"
},
{
"title": "EstimatorOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.EstimatorOptions"
},
{
"title": "ExecutionOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.ExecutionOptions"
},
{
"title": "ExecutionOptionsV2",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.ExecutionOptionsV2"
},
{
"title": "LayerNoiseLearningOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.LayerNoiseLearningOptions"
},
{
"title": "MeasureNoiseLearningOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.MeasureNoiseLearningOptions"
},
{
"title": "Options",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.Options"
},
{
"title": "PecOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.PecOptions"
},
{
"title": "ResilienceOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.ResilienceOptions"
},
{
"title": "ResilienceOptionsV2",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.ResilienceOptionsV2"
},
{
"title": "SamplerOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.SamplerOptions"
},
{
"title": "SimulatorOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.SimulatorOptions"
},
{
"title": "TranspilationOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.TranspilationOptions"
},
{
"title": "TwirlingOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.TwirlingOptions"
},
{
"title": "ZneOptions",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.options.ZneOptions"
}
]
},
Expand Down
60 changes: 51 additions & 9 deletions docs/api/qiskit-ibm-runtime/dev/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,39 @@ python_api_name: qiskit_ibm_runtime.options

Options that can be passed to the primitives.

The [`Options`](qiskit_ibm_runtime.options.Options "qiskit_ibm_runtime.options.Options") class encapsulates all the options you can specify when invoking a primitive. It includes frequently used options, such as `optimization_level` and `resilience_level` as well as sub-categories, such as `transpilation` and `execution`. You can use auto-complete to easily find the options inside each sub-category, for example:
**V2 Primitives**

`SamplerV2` and `EstimatorV2` each have their own options. You can use the `options` attribute to set the options. For example:

```python
from qiskit_ibm_runtime import QiskitRuntimeService, EstimatorV2

service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False)
estimator = EstimatorV2(backend=backend)
estimator.options.resilience_level = 1
```

You can also use the `update()` method to do bulk update. For example:

```python
from qiskit_ibm_runtime import QiskitRuntimeService, EstimatorV2

service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False)
estimator = EstimatorV2(backend=backend)
estimator.options.update(resilience_level=1)
```

Refer to [`SamplerOptions`](qiskit_ibm_runtime.options.SamplerOptions "qiskit_ibm_runtime.options.SamplerOptions") and [`EstimatorOptions`](qiskit_ibm_runtime.options.EstimatorOptions "qiskit_ibm_runtime.options.EstimatorOptions") for V2 Sampler and V2 Estimator options, respectively.

<Admonition title="Note" type="note">
If an option is not specified, the server default value is used. The default values are subject to change. See the [API Reference](/api/qiskit-ibm-runtime/options) for the most up-to-date default values.
</Admonition>

**V1 Primitives**

The [`Options`](qiskit_ibm_runtime.options.Options "qiskit_ibm_runtime.options.Options") class encapsulates all the options you can specify when invoking a V1 primitive. It includes frequently used options, such as `optimization_level` and `resilience_level` as well as sub-categories, such as `transpilation` and `execution`. You can use auto-complete to easily find the options inside each sub-category, for example:

```python
from qiskit_ibm_runtime.options import Options
Expand All @@ -37,12 +69,22 @@ options = Options(transpilation={"initial_layout": [0, 1, 2, 3]})

## Classes

| | |
| -------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
| [`Options`](qiskit_ibm_runtime.options.Options "qiskit_ibm_runtime.options.Options")(\[optimization\_level, ...]) | Options for the primitives. |
| [`TranspilationOptions`](qiskit_ibm_runtime.options.TranspilationOptions "qiskit_ibm_runtime.options.TranspilationOptions")(\[skip\_transpilation, ...]) | Transpilation options. |
| [`ResilienceOptions`](qiskit_ibm_runtime.options.ResilienceOptions "qiskit_ibm_runtime.options.ResilienceOptions")(\[noise\_amplifier, ...]) | Resilience options. |
| [`ExecutionOptions`](qiskit_ibm_runtime.options.ExecutionOptions "qiskit_ibm_runtime.options.ExecutionOptions")(\[shots, init\_qubits]) | Execution options. |
| [`EnvironmentOptions`](qiskit_ibm_runtime.options.EnvironmentOptions "qiskit_ibm_runtime.options.EnvironmentOptions")(\[log\_level, callback, ...]) | Options related to the execution environment. |
| [`SimulatorOptions`](qiskit_ibm_runtime.options.SimulatorOptions "qiskit_ibm_runtime.options.SimulatorOptions")(\[noise\_model, ...]) | Simulator options. |
| | |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| [`EstimatorOptions`](qiskit_ibm_runtime.options.EstimatorOptions "qiskit_ibm_runtime.options.EstimatorOptions")(\*args, \*\*kwargs) | Options for V2 Estimator. |
| [`SamplerOptions`](qiskit_ibm_runtime.options.SamplerOptions "qiskit_ibm_runtime.options.SamplerOptions")(\*args, \*\*kwargs) | Options for V2 Sampler. |
| [`DynamicalDecouplingOptions`](qiskit_ibm_runtime.options.DynamicalDecouplingOptions "qiskit_ibm_runtime.options.DynamicalDecouplingOptions")(\*args, \*\*kwargs) | Options for dynamical decoupling (DD). |
| [`ResilienceOptionsV2`](qiskit_ibm_runtime.options.ResilienceOptionsV2 "qiskit_ibm_runtime.options.ResilienceOptionsV2")(\*args, \*\*kwargs) | Resilience options for V2 Estimator. |
| [`LayerNoiseLearningOptions`](qiskit_ibm_runtime.options.LayerNoiseLearningOptions "qiskit_ibm_runtime.options.LayerNoiseLearningOptions")(\*args, \*\*kwargs) | Options for learning layer noise. |
| [`MeasureNoiseLearningOptions`](qiskit_ibm_runtime.options.MeasureNoiseLearningOptions "qiskit_ibm_runtime.options.MeasureNoiseLearningOptions")(\*args, \*\*kwargs) | Options for measurement noise learning. |
| [`PecOptions`](qiskit_ibm_runtime.options.PecOptions "qiskit_ibm_runtime.options.PecOptions")(\*args, \*\*kwargs) | Probabalistic error cancellation mitigation options. |
| [`ZneOptions`](qiskit_ibm_runtime.options.ZneOptions "qiskit_ibm_runtime.options.ZneOptions")(\*args, \*\*kwargs) | Zero noise extrapolation mitigation options. |
| [`TwirlingOptions`](qiskit_ibm_runtime.options.TwirlingOptions "qiskit_ibm_runtime.options.TwirlingOptions")(\*args, \*\*kwargs) | Twirling options. |
| [`ExecutionOptionsV2`](qiskit_ibm_runtime.options.ExecutionOptionsV2 "qiskit_ibm_runtime.options.ExecutionOptionsV2")(\*args, \*\*kwargs) | Execution options for V2 primitives. |
| [`Options`](qiskit_ibm_runtime.options.Options "qiskit_ibm_runtime.options.Options")(\[optimization\_level, ...]) | Options for the primitives, used by V1 primitives. |
| [`TranspilationOptions`](qiskit_ibm_runtime.options.TranspilationOptions "qiskit_ibm_runtime.options.TranspilationOptions")(\*args, \*\*kwargs) | Transpilation options. |
| [`ResilienceOptions`](qiskit_ibm_runtime.options.ResilienceOptions "qiskit_ibm_runtime.options.ResilienceOptions")(\*args, \*\*kwargs) | Resilience options for V1 primitives. |
| [`ExecutionOptions`](qiskit_ibm_runtime.options.ExecutionOptions "qiskit_ibm_runtime.options.ExecutionOptions")(\*args, \*\*kwargs) | Execution options for V1 primitives. |
| [`EnvironmentOptions`](qiskit_ibm_runtime.options.EnvironmentOptions "qiskit_ibm_runtime.options.EnvironmentOptions")(\*args, \*\*kwargs) | Options related to the execution environment. |
| [`SimulatorOptions`](qiskit_ibm_runtime.options.SimulatorOptions "qiskit_ibm_runtime.options.SimulatorOptions")(\*args, \*\*kwargs) | Simulator options. |

137 changes: 2 additions & 135 deletions docs/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.Estimator.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,144 +2,11 @@
title: Estimator
description: API reference for qiskit_ibm_runtime.Estimator
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_type: attribute
python_api_name: qiskit_ibm_runtime.Estimator
---

# Estimator

<span id="qiskit_ibm_runtime.Estimator" />

`Estimator(backend=None, session=None, options=None)` [GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/estimator.py#L36-L219 "view source code")

Class for interacting with Qiskit Runtime Estimator primitive service.

Qiskit Runtime Estimator primitive service estimates expectation values of quantum circuits and observables.

The [`run()`](#qiskit_ibm_runtime.Estimator.run "qiskit_ibm_runtime.Estimator.run") can be used to submit circuits, observables, and parameters to the Estimator primitive.

You are encouraged to use [`Session`](qiskit_ibm_runtime.Session "qiskit_ibm_runtime.Session") to open a session, during which you can invoke one or more primitives. Jobs submitted within a session are prioritized by the scheduler, and data is cached for efficiency.

Example:

```python
from qiskit.circuit.library import RealAmplitudes
from qiskit.quantum_info import SparsePauliOp

from qiskit_ibm_runtime import QiskitRuntimeService, Estimator

service = QiskitRuntimeService(channel="ibm_cloud")

psi1 = RealAmplitudes(num_qubits=2, reps=2)

H1 = SparsePauliOp.from_list([("II", 1), ("IZ", 2), ("XI", 3)])
H2 = SparsePauliOp.from_list([("IZ", 1)])
H3 = SparsePauliOp.from_list([("ZI", 1), ("ZZ", 1)])

with Session(service=service, backend="ibmq_qasm_simulator") as session:
estimator = Estimator(session=session)

theta1 = [0, 1, 1, 2, 3, 5]

# calculate [ <psi1(theta1)|H1|psi1(theta1)> ]
psi1_H1 = estimator.run(circuits=[psi1], observables=[H1], parameter_values=[theta1])
print(psi1_H1.result())

# calculate [ <psi1(theta1)|H2|psi1(theta1)>, <psi1(theta1)|H3|psi1(theta1)> ]
psi1_H23 = estimator.run(
circuits=[psi1, psi1],
observables=[H2, H3],
parameter_values=[theta1]*2
)
print(psi1_H23.result())
```

Initializes the Estimator primitive.

**Parameters**

* **backend** (`Union`\[`str`, [`IBMBackend`](qiskit_ibm_runtime.IBMBackend "qiskit_ibm_runtime.ibm_backend.IBMBackend"), `None`]) – Backend to run the primitive. This can be a backend name or an [`IBMBackend`](qiskit_ibm_runtime.IBMBackend "qiskit_ibm_runtime.IBMBackend") instance. If a name is specified, the default account (e.g. `QiskitRuntimeService()`) is used.

* **session** (`Union`\[[`Session`](qiskit_ibm_runtime.Session "qiskit_ibm_runtime.session.Session"), `str`, [`IBMBackend`](qiskit_ibm_runtime.IBMBackend "qiskit_ibm_runtime.ibm_backend.IBMBackend"), `None`]) –

Session in which to call the primitive.

If both `session` and `backend` are specified, `session` takes precedence. If neither is specified, and the primitive is created inside a [`qiskit_ibm_runtime.Session`](qiskit_ibm_runtime.Session "qiskit_ibm_runtime.Session") context manager, then the session is used. Otherwise if IBM Cloud channel is used, a default backend is selected.

* **options** (`Union`\[`Dict`, [`Options`](qiskit_ibm_runtime.options.Options "qiskit_ibm_runtime.options.options.Options"), `None`]) – Primitive options, see `Options` for detailed description. The `backend` keyword is still supported but is deprecated.

## Attributes

<span id="qiskit_ibm_runtime.Estimator.options" />

### options

Return options values for the sampler.

**Return type**

`Options`

**Returns**

options

<span id="qiskit_ibm_runtime.Estimator.session" />

### session

Return session used by this primitive.

**Return type**

`Optional`\[[`Session`](qiskit_ibm_runtime.Session "qiskit_ibm_runtime.session.Session")]

**Returns**

Session used by this primitive, or `None` if session is not used.

## Methods

### run

<span id="qiskit_ibm_runtime.Estimator.run" />

`run(circuits, observables, parameter_values=None, **kwargs)`

Submit a request to the estimator primitive.

**Parameters**

* **circuits** (*QuantumCircuit | Sequence\[QuantumCircuit]*) – a (parameterized) `QuantumCircuit` or a list of (parameterized) `QuantumCircuit`.
* **observables** (*BaseOperator | Sequence\[BaseOperator]*) – Observable objects.
* **parameter\_values** (*Sequence\[float] | Sequence\[Sequence\[float]] | None*) – Concrete parameters to be bound.
* **\*\*kwargs** – Individual options to overwrite the default primitive options. These include the runtime options in [`qiskit_ibm_runtime.RuntimeOptions`](qiskit_ibm_runtime.RuntimeOptions "qiskit_ibm_runtime.RuntimeOptions").

**Return type**

[RuntimeJob](qiskit_ibm_runtime.RuntimeJob "qiskit_ibm_runtime.RuntimeJob")

**Returns**

Submitted job. The result of the job is an instance of `qiskit.primitives.EstimatorResult`.

**Raises**

**ValueError** – Invalid arguments are given.

### set\_options

<span id="qiskit_ibm_runtime.Estimator.set_options" />

`set_options(**fields)` [GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/base_primitive.py#L225-L231 "view source code")

Set options values for the sampler.

**Parameters**

**\*\*fields** – The fields to update the options

**Return type**

`None`
alias of `EstimatorV1`

Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ Version of the backend being provided. This is not the same as `BackendV2.versio

<span id="qiskit_ibm_runtime.IBMBackend.__call__" />

`__call__()`
`__call__()` [GitHub](https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/ibm_backend.py#L506-L508 "view source code")

Call self as a function.

Expand Down
Loading

0 comments on commit 7a2ff9e

Please sign in to comment.