Skip to content

Commit

Permalink
Regenerate Qiskit 1.1 and Runtime 0.23 dev docs (Qiskit#1144)
Browse files Browse the repository at this point in the history
These haven't been generated in a long time. For Qiskit, this brings in
precise GitHub source code links from
Qiskit#517.
  • Loading branch information
Eric-Arellano authored Apr 9, 2024
1 parent 2eaf342 commit a23ce67
Show file tree
Hide file tree
Showing 770 changed files with 5,654 additions and 6,157 deletions.
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-runtime/dev/_toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"title": "Overview",
"url": "/api/qiskit-ibm-runtime/dev/runtime_service"
},
{
"title": "Batch",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.Batch"
},
{
"title": "EstimatorV1",
"url": "/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.EstimatorV1"
Expand Down
199 changes: 199 additions & 0 deletions docs/api/qiskit-ibm-runtime/dev/qiskit_ibm_runtime.Batch.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
---
title: Batch
description: API reference for qiskit_ibm_runtime.Batch
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit_ibm_runtime.Batch
---

# Batch

<Class id="qiskit_ibm_runtime.Batch" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/batch.py#L23-L102" signature="Batch(service=None, backend=None, max_time=None)">
Class for running jobs in batch execution mode.

Similar to a `session`, a Qiskit Runtime `batch` groups a collection of iterative calls to the quantum computer. Batch mode can shorten processing time if all jobs can be provided at the outset. To submit iterative jobs, use sessions instead.

**Using batch mode has these benefits:**

* The jobs’ classical computation, such as compilation, is run in parallel. Thus, running multiple jobs in a batch is significantly faster than running them serially.
* There is minimal delay between job, which can help avoid drift.

You can open a Qiskit Runtime batch by using this `Batch` class, then submit jobs to one or more primitives.

For example:

```python
from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime import Batch, SamplerV2 as Sampler

service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False)

# Bell Circuit
qr = QuantumRegister(2, name="qr")
cr = ClassicalRegister(2, name="cr")
qc = QuantumCircuit(qr, cr, name="bell")
qc.h(qr[0])
qc.cx(qr[0], qr[1])
qc.measure(qr, cr)

pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(qc)

with Batch(backend=backend) as batch:
sampler = Sampler(batch)
job = sampler.run([isa_circuit])
pub_result = job.result()[0]
print(f"Sampler job ID: {job.job_id()}")
print(f"Counts: {pub_result.data.cr.get_counts()}")
```

Batch constructor.

**Parameters**

* **service** (`Optional`\[[`QiskitRuntimeService`](qiskit_ibm_runtime.QiskitRuntimeService "qiskit_ibm_runtime.qiskit_runtime_service.QiskitRuntimeService")]) – Optional instance of the `QiskitRuntimeService` class. If `None`, the service associated with the backend, if known, is used. Otherwise `QiskitRuntimeService()` is used to initialize your default saved account.
* **backend** (`Union`\[`str`, `BackendV1`, `BackendV2`, `None`]) – Optional instance of `Backend` class or backend string name.
* **max\_time** (`Union`\[`int`, `str`, `None`]) – Maximum amount of time a runtime session can be open before being forcibly closed. Can be specified as seconds (int) or a string like “2h 30m 40s”. This value must be less than the [system imposed maximum](/run/max-execution-time).

**Raises**

**ValueError** – If an input value is invalid.

## Attributes

### service

<Attribute id="qiskit_ibm_runtime.Batch.service" name="service">
Return service associated with this session.

**Return type**

[`QiskitRuntimeService`](qiskit_ibm_runtime.QiskitRuntimeService "qiskit_ibm_runtime.qiskit_runtime_service.QiskitRuntimeService")

**Returns**

[`qiskit_ibm_runtime.QiskitRuntimeService`](qiskit_ibm_runtime.QiskitRuntimeService "qiskit_ibm_runtime.QiskitRuntimeService") associated with this session.
</Attribute>

### session\_id

<Attribute id="qiskit_ibm_runtime.Batch.session_id" name="session_id">
Return the session ID.

**Return type**

`Optional`\[`str`]

**Returns**

Session ID. None if the backend is a simulator.
</Attribute>

## Methods

### backend

<Function id="qiskit_ibm_runtime.Batch.backend" name="backend" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/session.py#L235-L243" signature="backend()">
Return backend for this session.

**Return type**

`Optional`\[`str`]

**Returns**

Backend for this session. None if unknown.
</Function>

### cancel

<Function id="qiskit_ibm_runtime.Batch.cancel" name="cancel" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/session.py#L221-L225" signature="cancel()">
Cancel all pending jobs in a session.

**Return type**

`None`
</Function>

### close

<Function id="qiskit_ibm_runtime.Batch.close" name="close" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/session.py#L227-L233" signature="close()">
Close the session so new jobs will no longer be accepted, but existing queued or running jobs will run to completion. The session will be terminated once there are no more pending jobs.

**Return type**

`None`
</Function>

### details

<Function id="qiskit_ibm_runtime.Batch.details" name="details" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/session.py#L271-L307" signature="details()">
Return session details.

**Returns**

id: id of the session. backend\_name: backend used for the session. interactive\_timeout: The maximum idle time (in seconds) between jobs that is allowed to occur before the session is deactivated. max\_time: Maximum allowed time (in seconds) for the session, subject to plan limits. active\_timeout: The maximum time (in seconds) a session can stay active. state: State of the session - open, active, inactive, or closed. accepting\_jobs: Whether or not the session is accepting jobs. last\_job\_started: Timestamp of when the last job in the session started. last\_job\_completed: Timestamp of when the last job in the session completed. started\_at: Timestamp of when the session was started. closed\_at: Timestamp of when the session was closed. activated\_at: Timestamp of when the session state was changed to active.

**Return type**

A dictionary with the sessions details, including
</Function>

### from\_id

<Function id="qiskit_ibm_runtime.Batch.from_id" name="from_id" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/session.py#L327-L352" signature="classmethod from_id(session_id, service=None, backend=None)">
Construct a Session object with a given session\_id

**Parameters**

* **session\_id** (`str`) – the id of the session to be created. This must be an already existing session id.
* **service** (`Optional`\[[`QiskitRuntimeService`](qiskit_ibm_runtime.QiskitRuntimeService "qiskit_ibm_runtime.qiskit_runtime_service.QiskitRuntimeService")]) – instance of the `QiskitRuntimeService` class.
* **backend** (`Union`\[`str`, [`IBMBackend`](qiskit_ibm_runtime.IBMBackend "qiskit_ibm_runtime.ibm_backend.IBMBackend"), `None`]) – instance of [`qiskit_ibm_runtime.IBMBackend`](qiskit_ibm_runtime.IBMBackend "qiskit_ibm_runtime.IBMBackend") class or string name of backend.

**Return type**

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

**Returns**

A new Session with the given `session_id`
</Function>

### run

<Function id="qiskit_ibm_runtime.Batch.run" name="run" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/session.py#L169-L219" signature="run(program_id, inputs, options=None, callback=None, result_decoder=None)">
Run a program in the session.

**Parameters**

* **program\_id** (`str`) – Program ID.
* **inputs** (`Dict`) – Program input parameters. These input values are passed to the runtime program.
* **options** (`Optional`\[`Dict`]) – Runtime options that control the execution environment. See [`qiskit_ibm_runtime.RuntimeOptions`](qiskit_ibm_runtime.RuntimeOptions "qiskit_ibm_runtime.RuntimeOptions") for all available options.
* **callback** (`Optional`\[`Callable`]) – Callback function to be invoked for any interim results and final result.

**Return type**

`Union`\[[`RuntimeJob`](qiskit_ibm_runtime.RuntimeJob "qiskit_ibm_runtime.runtime_job.RuntimeJob"), [`RuntimeJobV2`](qiskit_ibm_runtime.RuntimeJobV2 "qiskit_ibm_runtime.runtime_job_v2.RuntimeJobV2")]

**Returns**

Submitted job.
</Function>

### status

<Function id="qiskit_ibm_runtime.Batch.status" name="status" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/session.py#L245-L269" signature="status()">
Return current session status.

**Returns**

Pending: Session is created but not active. It will become active when the next job of this session is dequeued. In progress, accepting new jobs: session is active and accepting new jobs. In progress, not accepting new jobs: session is active and not accepting new jobs. Closed: max\_time expired or session was explicitly closed. None: status details are not available.

**Return type**

The current status of the session, including
</Function>
</Class>

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ python_api_name: qiskit_ibm_runtime.Estimator

# Estimator

<Attribute id="qiskit_ibm_runtime.Estimator" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/estimator.py#L179-L363">
<Attribute id="qiskit_ibm_runtime.Estimator" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/estimator.py#L182-L366">
alias of [`EstimatorV1`](qiskit_ibm_runtime.EstimatorV1 "qiskit_ibm_runtime.estimator.EstimatorV1")
</Attribute>

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ python_api_name: qiskit_ibm_runtime.EstimatorV1

# EstimatorV1

<Class id="qiskit_ibm_runtime.EstimatorV1" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/estimator.py#L179-L363" signature="EstimatorV1(backend=None, session=None, options=None)">
<Class id="qiskit_ibm_runtime.EstimatorV1" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/estimator.py#L182-L366" signature="EstimatorV1(backend=None, session=None, options=None)">
Class for interacting with Qiskit Runtime Estimator primitive service.

Qiskit Runtime Estimator primitive service estimates expectation values of quantum circuits and observables.
Expand Down Expand Up @@ -95,7 +95,7 @@ python_api_name: qiskit_ibm_runtime.EstimatorV1

### run

<Function id="qiskit_ibm_runtime.EstimatorV1.run" name="run" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/estimator.py#L258-L292" signature="run(circuits, observables, parameter_values=None, **kwargs)">
<Function id="qiskit_ibm_runtime.EstimatorV1.run" name="run" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/estimator.py#L261-L295" signature="run(circuits, observables, parameter_values=None, **kwargs)">
Submit a request to the estimator primitive.

**Parameters**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ python_api_name: qiskit_ibm_runtime.EstimatorV2

# EstimatorV2

<Class id="qiskit_ibm_runtime.EstimatorV2" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/estimator.py#L48-L176" signature="EstimatorV2(backend=None, session=None, options=None)">
<Class id="qiskit_ibm_runtime.EstimatorV2" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/estimator.py#L49-L179" signature="EstimatorV2(backend=None, session=None, options=None)">
Class for interacting with Qiskit Runtime Estimator primitive service.

Qiskit Runtime Estimator primitive service estimates expectation values of quantum circuits and observables.
Expand Down Expand Up @@ -101,7 +101,7 @@ python_api_name: qiskit_ibm_runtime.EstimatorV2

### run

<Function id="qiskit_ibm_runtime.EstimatorV2.run" name="run" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/estimator.py#L136-L153" signature="run(pubs, *, precision=None)">
<Function id="qiskit_ibm_runtime.EstimatorV2.run" name="run" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/estimator.py#L134-L151" signature="run(pubs, *, precision=None)">
Submit a request to the estimator primitive.

**Parameters**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ python_api_name: qiskit_ibm_runtime.RuntimeDecoder

# RuntimeDecoder

<Class id="qiskit_ibm_runtime.RuntimeDecoder" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/utils/json.py#L328-L422" signature="RuntimeDecoder(*args, **kwargs)">
<Class id="qiskit_ibm_runtime.RuntimeDecoder" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/utils/json.py#L327-L418" signature="RuntimeDecoder(*args, **kwargs)">
JSON Decoder used by runtime service.

`object_hook`, if specified, will be called with the result of every JSON object decoded and its return value will be used in place of the given `dict`. This can be used to provide custom deserializations (e.g. to support JSON-RPC class hinting).
Expand All @@ -33,7 +33,7 @@ python_api_name: qiskit_ibm_runtime.RuntimeDecoder

### object\_hook

<Function id="qiskit_ibm_runtime.RuntimeDecoder.object_hook" name="object_hook" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/utils/json.py#L343-L422" signature="object_hook(obj)">
<Function id="qiskit_ibm_runtime.RuntimeDecoder.object_hook" name="object_hook" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/utils/json.py#L339-L418" signature="object_hook(obj)">
Called to decode object.

**Return type**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ python_api_name: qiskit_ibm_runtime.RuntimeEncoder

# RuntimeEncoder

<Class id="qiskit_ibm_runtime.RuntimeEncoder" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/utils/json.py#L207-L325" signature="RuntimeEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)">
<Class id="qiskit_ibm_runtime.RuntimeEncoder" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/utils/json.py#L206-L324" signature="RuntimeEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)">
JSON Encoder used by runtime service.

Constructor for JSONEncoder, with sensible defaults.
Expand Down Expand Up @@ -43,7 +43,7 @@ python_api_name: qiskit_ibm_runtime.RuntimeEncoder

### default

<Function id="qiskit_ibm_runtime.RuntimeEncoder.default" name="default" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/utils/json.py#L210-L325" signature="default(obj)">
<Function id="qiskit_ibm_runtime.RuntimeEncoder.default" name="default" github="https://github.com/Qiskit/qiskit-ibm-runtime/tree/main/qiskit_ibm_runtime/utils/json.py#L209-L324" signature="default(obj)">
Implement this method in a subclass such that it returns a serializable object for `o`, or calls the base implementation (to raise a `TypeError`).

For example, to support arbitrary iterators, you could implement default like this:
Expand Down
Loading

0 comments on commit a23ce67

Please sign in to comment.