Skill Tracer
Skills › Scientific Agent Skills › pennylane › devices_backends.md

devices_backends.md

172 lines · skills/pennylane/references/devices_backends.md at 5f2bc03

Open on GitHub
1# Devices and backend boundaries
2
3PennyLane 0.45.1 is the tested core. Provider integrations below were checked
4against official docs/released source, **not authenticated hardware jobs**.
5Install each provider/compiler in a separate environment and resolve its declared
6requirements; a plugin version number does not guarantee all current backend APIs.
7

Devices and backend boundaries

PennyLane 0.45.1 is the tested core. Provider integrations below were checked against official docs/released source, not authenticated hardware jobs. Install each provider/compiler in a separate environment and resolve its declared requirements; a plugin version number does not guarantee all current backend APIs.

Raw lines 1 to 7
8## Local simulators and reusable circuits
9
10```python
11import pennylane as qml
12from pennylane import numpy as np
14def quantum_function(theta):
15 qml.RY(theta, wires=0)
16 qml.CNOT(wires=[0, 1])
17 return qml.expval(qml.Z(1))
19results = {}
20for name in ["default.qubit", "lightning.qubit", "default.mixed"]:
21 dev = qml.device(name, wires=2)
22 circuit = qml.QNode(quantum_function, dev, diff_method="parameter-shift")
23 theta = np.array(0.3, requires_grad=True)
24 results[name] = float(circuit(theta))
25 assert np.allclose(results[name], np.cos(theta))
26 assert np.allclose(qml.grad(circuit)(theta), -np.sin(theta))
27```
29`default.mixed` supports explicit channels; changing to it does not automatically
30apply a realistic hardware noise model. Lightning speedups depend on circuit size
31and overhead. `lightning.gpu` requires its separate CUDA/cuQuantum-compatible
32plugin and hardware; no GPU fallback should silently change a reported benchmark.
33`default.clifford` needs Stim and accepts only its supported Clifford operations
34and measurements (some Pauli rotations at Clifford angles may be supported).
35There is no universal fixed qubit limit or provider noise ranking.
37Use `dev.name`, `dev.wires` and `len(dev.wires)` when wires are allocated. New
38Device API objects do not universally expose legacy `num_wires`, `operations`,
39`observables` or `apply`. Some use dynamic wires or optional capabilities objects.
40Inspect each device's documented preprocessing and derivative support; run a tiny
41representative circuit. For custom devices implement the current execution and
42preprocessing protocol, not an obsolete `DefaultQubit.apply` override. A custom
43operator can implement `compute_decomposition`; registering an arbitrary attribute
44on `qml.ops` is not plugin registration.

Local simulators and reusable circuits

import pennylane as qml
from pennylane import numpy as np

def quantum_function(theta):
    qml.RY(theta, wires=0)
    qml.CNOT(wires=[0, 1])
    return qml.expval(qml.Z(1))

results = {}
for name in ["default.qubit", "lightning.qubit", "default.mixed"]:
    dev = qml.device(name, wires=2)
    circuit = qml.QNode(quantum_function, dev, diff_method="parameter-shift")
    theta = np.array(0.3, requires_grad=True)
    results[name] = float(circuit(theta))
    assert np.allclose(results[name], np.cos(theta))
    assert np.allclose(qml.grad(circuit)(theta), -np.sin(theta))

default.mixed supports explicit channels; changing to it does not automatically apply a realistic hardware noise model. Lightning speedups depend on circuit size and overhead. lightning.gpu requires its separate CUDA/cuQuantum-compatible plugin and hardware; no GPU fallback should silently change a reported benchmark. default.clifford needs Stim and accepts only its supported Clifford operations and measurements (some Pauli rotations at Clifford angles may be supported). There is no universal fixed qubit limit or provider noise ranking.

Use dev.name, dev.wires and len(dev.wires) when wires are allocated. New Device API objects do not universally expose legacy num_wires, operations, observables or apply. Some use dynamic wires or optional capabilities objects. Inspect each device's documented preprocessing and derivative support; run a tiny representative circuit. For custom devices implement the current execution and preprocessing protocol, not an obsolete DefaultQubit.apply override. A custom operator can implement compute_decomposition; registering an arbitrary attribute on qml.ops is not plugin registration.

Raw lines 8 to 45
46## Provider installation targets
48These released versions were source/metadata checked on 2026-10-01. Commands are
49illustrative dependency setup, not a tested combined environment:
51```bash
52# Choose one provider per environment.
53uv pip install "pennylane==0.45.1" "pennylane-qiskit==0.45.0"
54uv pip install "pennylane==0.45.1" "amazon-braket-pennylane-plugin==1.35.2"
55uv pip install "pennylane==0.45.1" "pennylane-cirq==0.44.0"
56uv pip install "pennylane==0.45.1" "pennylane-ionq==0.45.0"
57```
59Rigetti's last published plugin is 0.40.0, with `pyquil<4` and `networkx<3`;
60resolve and validate it in its own legacy stack instead of installing it into the
61current core/ML environment. Current QCS hardware availability requires provider
62verification. Strawberry Fields' plugin documentation targets 0.29.1; an old
63`strawberryfields.remote`/Borealis recipe is not evidence of compatibility or a
64currently accessible backend with PennyLane 0.45.1.

Provider installation targets

These released versions were source/metadata checked on 2026-10-01. Commands are illustrative dependency setup, not a tested combined environment:

# Choose one provider per environment.
uv pip install "pennylane==0.45.1" "pennylane-qiskit==0.45.0"
uv pip install "pennylane==0.45.1" "amazon-braket-pennylane-plugin==1.35.2"
uv pip install "pennylane==0.45.1" "pennylane-cirq==0.44.0"
uv pip install "pennylane==0.45.1" "pennylane-ionq==0.45.0"

Rigetti's last published plugin is 0.40.0, with pyquil<4 and networkx<3; resolve and validate it in its own legacy stack instead of installing it into the current core/ML environment. Current QCS hardware availability requires provider verification. Strawberry Fields' plugin documentation targets 0.29.1; an old strawberryfields.remote/Borealis recipe is not evidence of compatibility or a currently accessible backend with PennyLane 0.45.1.

Raw lines 46 to 65
66## IBM Quantum: backend object and finite shots
68`qiskit.aer` is a local simulator plugin. `qiskit.remote` accepts a Qiskit backend
69object and uses EstimatorV2/SamplerV2. Allocate only the logical wires needed,
70within backend capacity. Its execution is sampled; do not promise analytic results.
72Illustrative authenticated setup, not executed:
74```python
75import os
76import pennylane as qml
77from qiskit_ibm_runtime import QiskitRuntimeService
79service = QiskitRuntimeService(
80 channel="ibm_quantum_platform",
81 token=os.environ["IBM_QUANTUM_API_KEY"],
82 instance=os.environ["IBM_QUANTUM_INSTANCE"],
84backend = service.least_busy(operational=True, simulator=False, min_num_qubits=2)
85dev = qml.device("qiskit.remote", wires=2, backend=backend)
86@qml.set_shots(1024)
87@qml.qnode(dev, diff_method="parameter-shift")
88def hardware_circuit(theta):
89 qml.RY(theta, wires=0)
90 qml.CNOT(wires=[0, 1])
91 return qml.expval(qml.Z(1))
92# Calling hardware_circuit submits work; record backend, calibration, shots and job metadata.
93```
95The environment variable names here are application-defined inputs, not automatic
96SDK credential discovery. Saved credentials are another option:
97`QiskitRuntimeService.save_account(...)` saves configuration; then construct
98`QiskitRuntimeService()` separately. Do not assign `save_account`'s return value as
99the service. The SDK resolves the IBM platform URL and handles authentication;
100this skill does not implement a parallel REST client. Source docs and released
101plugin source differ on the behavior of unspecified shots, so set an explicit
102finite integer. Shot vectors are not supported by this plugin release.

IBM Quantum: backend object and finite shots

qiskit.aer is a local simulator plugin. qiskit.remote accepts a Qiskit backend object and uses EstimatorV2/SamplerV2. Allocate only the logical wires needed, within backend capacity. Its execution is sampled; do not promise analytic results.

Illustrative authenticated setup, not executed:

import os
import pennylane as qml
from qiskit_ibm_runtime import QiskitRuntimeService

service = QiskitRuntimeService(
    channel="ibm_quantum_platform",
    token=os.environ["IBM_QUANTUM_API_KEY"],
    instance=os.environ["IBM_QUANTUM_INSTANCE"],
)
backend = service.least_busy(operational=True, simulator=False, min_num_qubits=2)
dev = qml.device("qiskit.remote", wires=2, backend=backend)
@qml.set_shots(1024)
@qml.qnode(dev, diff_method="parameter-shift")
def hardware_circuit(theta):
    qml.RY(theta, wires=0)
    qml.CNOT(wires=[0, 1])
    return qml.expval(qml.Z(1))
# Calling hardware_circuit submits work; record backend, calibration, shots and job metadata.

The environment variable names here are application-defined inputs, not automatic SDK credential discovery. Saved credentials are another option: QiskitRuntimeService.save_account(...) saves configuration; then construct QiskitRuntimeService() separately. Do not assign save_account's return value as the service. The SDK resolves the IBM platform URL and handles authentication; this skill does not implement a parallel REST client. Source docs and released plugin source differ on the behavior of unspecified shots, so set an explicit finite integer. Shot vectors are not supported by this plugin release.

Raw lines 66 to 103
104## Amazon Braket
106The plugin provides `braket.local.qubit` for local execution and
107`braket.aws.qubit` for cloud tasks. Cloud construction uses `device_arn`, `wires`
108and optional `s3_destination_folder=(bucket, prefix)`; use a bucket the account
109owns/accesses. AWS SDK credentials and correct region are required for cloud use.
110Discover the currently available device ARN with the Braket console/SDK and check
111status, supported operations, shots and result types before selecting it. Do not
112copy a historical Harmony ARN or an example bucket name into a live request.
113The documented SV1 ARN is `arn:aws:braket:::device/quantum-simulator/amazon/sv1`;
114a cloud simulator can still incur cost. No Braket task was submitted here.

Amazon Braket

The plugin provides braket.local.qubit for local execution and braket.aws.qubit for cloud tasks. Cloud construction uses device_arn, wires and optional s3_destination_folder=(bucket, prefix); use a bucket the account owns/accesses. AWS SDK credentials and correct region are required for cloud use. Discover the currently available device ARN with the Braket console/SDK and check status, supported operations, shots and result types before selecting it. Do not copy a historical Harmony ARN or an example bucket name into a live request. The documented SV1 ARN is arn:aws:braket:::device/quantum-simulator/amazon/sv1; a cloud simulator can still incur cost. No Braket task was submitted here.

Raw lines 104 to 115
116## Cirq, Rigetti and photonics
118The Cirq 0.44.0 plugin registers `cirq.simulator`, `cirq.mixedsimulator`,
119`cirq.qsim`, `cirq.qsimh` and `cirq.pasqal`. qsim requires its optional native
120package. **`cirq.pasqal` describes Pasqal neutral-atom devices, not Google's
121Rainbow hardware.** Google Quantum Engine access needs an appropriate current
122provider integration and access; do not infer it from installing the Cirq plugin.
124Rigetti's legacy entry points include `rigetti.qvm`, `rigetti.qpu` and wavefunction
125simulators. A QVM needs its runtime/services; a QPU needs current QCS credentials
126and a currently accessible processor. Do not hardcode retired Aspen targets or
127assume a QPU's number of qubits from an old example. Photonic workflows use different
128state spaces/operations; confirm the dedicated plugin/runtime instead of swapping
129a qubit QNode's device string to Borealis.

Cirq, Rigetti and photonics

The Cirq 0.44.0 plugin registers cirq.simulator, cirq.mixedsimulator, cirq.qsim, cirq.qsimh and cirq.pasqal. qsim requires its optional native package. **cirq.pasqal describes Pasqal neutral-atom devices, not Google's Rainbow hardware.** Google Quantum Engine access needs an appropriate current provider integration and access; do not infer it from installing the Cirq plugin.

Rigetti's legacy entry points include rigetti.qvm, rigetti.qpu and wavefunction simulators. A QVM needs its runtime/services; a QPU needs current QCS credentials and a currently accessible processor. Do not hardcode retired Aspen targets or assume a QPU's number of qubits from an old example. Photonic workflows use different state spaces/operations; confirm the dedicated plugin/runtime instead of swapping a qubit QNode's device string to Borealis.

Raw lines 116 to 130
131## IonQ: explicit current backend target
133The released `pennylane-ionq==0.45.0` package registers `ionq.simulator` and
134`ionq.qpu`. It reads an explicit `api_key`, then `PENNYLANE_IONQ_API_KEY`, then
135`IONQ_API_KEY`. Its client uses IonQ API v0.4 and `Authorization: apiKey ...`.
136An `ionq.simulator` circuit still uses the remote service and credentials.
138For hardware, provide a currently discovered `target` explicitly. The released
139plugin's generic `target="qpu"` fallback still rewrites to `qpu.aria-1`, while
140current v0.4 create-job documentation lists Forte targets. That fallback is not
141verified as usable. Do not interpret plugin defaults as current availability.
142The source creates JSON jobs with `type`, `backend` and `input`; the service returns
143a job ID/status and requires polling/result retrieval. The plugin handles those
144contracts. No authentication or paid execution was attempted in this refresh.

IonQ: explicit current backend target

The released pennylane-ionq==0.45.0 package registers ionq.simulator and ionq.qpu. It reads an explicit api_key, then PENNYLANE_IONQ_API_KEY, then IONQ_API_KEY. Its client uses IonQ API v0.4 and Authorization: apiKey .... An ionq.simulator circuit still uses the remote service and credentials.

For hardware, provide a currently discovered target explicitly. The released plugin's generic target="qpu" fallback still rewrites to qpu.aria-1, while current v0.4 create-job documentation lists Forte targets. That fallback is not verified as usable. Do not interpret plugin defaults as current availability. The source creates JSON jobs with type, backend and input; the service returns a job ID/status and requires polling/result retrieval. The plugin handles those contracts. No authentication or paid execution was attempted in this refresh.

Raw lines 131 to 145
146## Shots, reproducibility and operations
148Use `qml.set_shots(circuit, shots=1000)` to produce a configured QNode and
149`shots=None` only on devices supporting analytic execution. A seeded simulator
150advances its RNG between calls; recreating the device reproduces the sequence.
151Do not globally cache one stateful device across independent concurrent experiments
152without understanding its state, random stream and backend thread safety.
154Before hardware execution, budget parameter shifts, measurement groups, repetitions
155and shots, record the job identifier, and inspect failed/pending jobs before
156retrying. Blind resubmission can duplicate charged work. Provider queue/calibration
157and device topology drift require live checks. A matched local output establishes
158circuit semantics only, not hardware fidelity or access.

Shots, reproducibility and operations

Use qml.set_shots(circuit, shots=1000) to produce a configured QNode and shots=None only on devices supporting analytic execution. A seeded simulator advances its RNG between calls; recreating the device reproduces the sequence. Do not globally cache one stateful device across independent concurrent experiments without understanding its state, random stream and backend thread safety.

Before hardware execution, budget parameter shifts, measurement groups, repetitions and shots, record the job identifier, and inspect failed/pending jobs before retrying. Blind resubmission can duplicate charged work. Provider queue/calibration and device topology drift require live checks. A matched local output establishes circuit semantics only, not hardware fidelity or access.

Raw lines 146 to 159
160## Primary sources
162- [Device API](https://docs.pennylane.ai/en/stable/code/api/pennylane.devices.Device.html)
163- [Lightning](https://docs.pennylane.ai/projects/lightning/en/stable/)
164- [Qiskit remote device](https://docs.pennylane.ai/projects/qiskit/en/stable/devices/remote.html)
165- [IBM runtime service](https://quantum.cloud.ibm.com/docs/en/api/qiskit-ibm-runtime/qiskit-runtime-service)
166- [Released Qiskit device source](https://github.com/PennyLaneAI/pennylane-qiskit/blob/v0.45.0/pennylane_qiskit/qiskit_device.py)
167- [Braket plugin](https://amazon-braket-pennylane-plugin-python.readthedocs.io/en/latest/)
168- [Cirq entry points](https://github.com/PennyLaneAI/pennylane-cirq/blob/v0.44.0/setup.py)
169- [Rigetti release](https://pypi.org/project/PennyLane-Rigetti/0.40.0/)
170- [Strawberry Fields plugin](https://docs.pennylane.ai/projects/strawberryfields/en/latest/)
171- [IonQ release](https://pypi.org/project/PennyLane-IonQ/0.45.0/)
172- [IonQ v0.4 create-job contract](https://docs.ionq.com/api-reference/v0.4/jobs/create-job)