Skip to main content

Local Braket Qubit Executor

This quantum executor accesses the local Braket quantum circuit simulator ("braket.local.qubit").

It utilizes the Pennylane plugin found here. LocalBraketQubitExecutor introduces thread-based parallelism for circuit execution on the "braket.local.qubit" device.

1. Installation

LocalBraketQubitExecutor is included in Covalent. To use it, however, you will need to install the amazon-braket-pennylane-plugin:

pip install amazon-braket-pennylane-plugin

2. Usage Example

Using LocalBraketQubitExecutor is simple:

# Local simulator
executor = ct.executor.LocalBraketQubitExecutor(
device="default",
shots=1024,
num_threads=2
)

@ct.qelectron(executors=executor)
@qml.qnode(qml.device("default.qubit", wires=2, shots=1024))
def circuit(x):
qml.IQPEmbedding(features=x, wires=[0, 1])
qml.Hadamard(wires=1)
return [qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1))]

As a QElectron, the circuit can be called either normally or asynchronously using circuit.run_later().

Synchronous example output is below

>>> print(circuit([0.5, 0.1]))

[array(0.008), array(0.996)]

and asynchronously:

>>> x = [0.6, -1.57]

>>> # Queue jobs for all three circuit calls simultaneously on.
>>> futs = [circuit.run_later(x) for _ in range(3)]

>>> # Wait for all circuits to finish.
>>> [fut.result() for fut in futs]

[[array(-0.02), array(0.01)],
[array(0.014), array(-0.022)],
[array(-0.074), array(0.05)]]

3. Overview of Configuration

The LocalBraketQubitExecutor configuration is found under [qelectron.LocalBraketQubitExecutor] in the Covalent configuration file.

ConfigIs RequiredDefaultDescription
backendNo"default"The type of simulator backend to be used. Choices are "default", "braket_sv", "braket_dm" and "braket_ahs".

pydantic model covalent.executor.LocalBraketQubitExecutor

#

The local Braket executor based on the existing Pennylane local Braket qubit device.

max_jobs

maximum number of parallel jobs sent by threads on batch_submit.

shots

number of shots used to estimate quantum observables.

backend

The name of the simulator backend. Defaults to the 'default' simulator backend name.

run_kwargs

Variable length keyword arguments for braket.devices.Device.run().

Show JSON Schema
{
"title": "LocalBraketQubitExecutor",
"description": "The local Braket executor based on the existing Pennylane local Braket qubit device.\n\nAttributes:\n max_jobs: maximum number of parallel jobs sent by processes on :code:`batch_submit`.\n shots: number of shots used to estimate quantum observables.\n backend:\n The name of the simulator backend. Defaults to the :code:`\"default\"`\n simulator backend name.\n run_kwargs: Variable length keyword arguments for :code:`braket.devices.Device.run()`.",
"type": "object",
"properties": {
"persist_data": {
"title": "Persist Data",
"default": true,
"type": "boolean"
},
"qnode_device_import_path": {
"title": "Qnode Device Import Path",
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": [
{
"type": "string"
},
{
"type": "string"
}
]
},
"qnode_device_shots": {
"title": "Qnode Device Shots",
"type": "integer"
},
"qnode_device_wires": {
"title": "Qnode Device Wires",
"type": "integer"
},
"pennylane_active_return": {
"title": "Pennylane Active Return",
"type": "boolean"
},
"device": {
"title": "Device",
"default": "default.qubit",
"type": "string"
},
"num_processes": {
"title": "Num Processes",
"default": 10,
"type": "integer"
},
"max_jobs": {
"title": "Max Jobs",
"default": 20,
"type": "integer"
},
"shots": {
"title": "Shots",
"type": "integer"
},
"backend": {
"title": "Backend",
"type": "string"
},
"run_kwargs": {
"title": "Run Kwargs",
"default": {},
"type": "object"
}
}
}

CONFIG

extra: EXTRA = allow

field backend: str [Optional]

#

Validated by

set_name

field max_jobs: int = 20

#

Validated by

set_name

field run_kwargs: dict = {}

#

Validated by

set_name

field shots: int = None

#

Validated by

set_name

batch_submit

#

Submit qscripts for execution using num_processes-many processes.

Parameters

qscripts_list (List): a list of Pennylane style QuantumScripts

Returns

a list of futures submitted by processes.

Return Type

jobs

dict

#

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.