Backends API Reference
HLQuantum translates its Circuit IR into the native representation of each backend.
All backends implement the Backend abstract base class and return a unified ExecutionResult.
Supported Backends
| Backend | Framework | GPU support | Install extra |
|---|---|---|---|
CudaQBackend |
NVIDIA CUDA-Q | Yes | pip install hlquantum[cudaq] |
QiskitBackend |
IBM Qiskit | Yes | pip install hlquantum[qiskit] |
CirqBackend |
Google Cirq | Yes | pip install hlquantum[cirq] |
BraketBackend |
Amazon Braket | No (cloud) | pip install hlquantum[braket] |
PennyLaneBackend |
Xanadu PennyLane | Yes | pip install hlquantum[pennylane] |
IonQBackend |
IonQ (qiskit-ionq) | No (cloud) | pip install hlquantum[ionq] |
Quick Examples
from hlquantum.backends import (
CudaQBackend, QiskitBackend, CirqBackend,
BraketBackend, PennyLaneBackend, IonQBackend,
)
import hlquantum as hlq
# CUDA-Q
result = hlq.run(circuit, backend=CudaQBackend())
# Qiskit (local Aer simulator)
result = hlq.run(circuit, backend=QiskitBackend())
# Cirq
result = hlq.run(circuit, backend=CirqBackend())
# Amazon Braket (local)
result = hlq.run(circuit, backend=BraketBackend())
# PennyLane
result = hlq.run(circuit, backend=PennyLaneBackend())
# IonQ (cloud simulator)
result = hlq.run(circuit, backend=IonQBackend(api_key="..."))
Adding a Custom Backend
from hlquantum.backends import Backend
from hlquantum.result import ExecutionResult
class MyBackend(Backend):
@property
def name(self) -> str:
return "my_backend"
def run(self, circuit, shots=1000, **kwargs):
# Translate circuit.gates → your framework, execute, collect counts
return ExecutionResult(counts={"00": shots}, shots=shots, backend_name=self.name)
Base Class
Abstract base class for backends.
Backend
Bases: ABC
Abstract quantum-execution backend.
Source code in hlquantum/backends/base.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
run(circuit, shots=1000, include_statevector=False, **kwargs)
abstractmethod
Execute circuit and return Result.
Source code in hlquantum/backends/base.py
29 30 31 32 33 34 35 36 37 38 | |
validate(circuit)
Validate circuit for this backend.
Source code in hlquantum/backends/base.py
40 41 42 43 | |
CUDA-Q
hlquantum.backends.cudaq_backend ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CUDA-Q backend for HLQuantum.
CudaQBackend
Bases: Backend
Execute HLQuantum circuits on NVIDIA CUDA-Q.
Source code in hlquantum/backends/cudaq_backend.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
run(circuit, shots=1000, include_statevector=False, **kwargs)
Sample circuit on CUDA-Q and return an :class:ExecutionResult.
Source code in hlquantum/backends/cudaq_backend.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
Qiskit
hlquantum.backends.qiskit_backend ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IBM Qiskit backend for HLQuantum.
QiskitBackend
Bases: Backend
Execute HLQuantum circuits using IBM Qiskit.
Source code in hlquantum/backends/qiskit_backend.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
run(circuit, shots=1000, include_statevector=False, **kwargs)
Transpile & run circuit on the configured Qiskit backend.
Source code in hlquantum/backends/qiskit_backend.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
Cirq
hlquantum.backends.cirq_backend ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Google Cirq backend for HLQuantum.
CirqBackend
Bases: Backend
Execute HLQuantum circuits using Google Cirq.
Source code in hlquantum/backends/cirq_backend.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
run(circuit, shots=1000, include_statevector=False, **kwargs)
Simulate circuit with Cirq and return an :class:ExecutionResult.
Source code in hlquantum/backends/cirq_backend.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
Amazon Braket
hlquantum.backends.braket_backend ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Amazon Braket backend for HLQuantum.
BraketBackend
Bases: Backend
Execute HLQuantum circuits using Amazon Braket.
Source code in hlquantum/backends/braket_backend.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
run(circuit, shots=1000, include_statevector=False, **kwargs)
Execute circuit with Amazon Braket and return an :class:ExecutionResult.
Source code in hlquantum/backends/braket_backend.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
PennyLane
hlquantum.backends.pennylane_backend ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PennyLane (Xanadu) backend for HLQuantum.
PennyLaneBackend
Bases: Backend
Execute HLQuantum circuits using Xanadu PennyLane.
Source code in hlquantum/backends/pennylane_backend.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
run(circuit, shots=1000, include_statevector=False, **kwargs)
Execute circuit with PennyLane and return an :class:ExecutionResult.
Source code in hlquantum/backends/pennylane_backend.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
IonQ
hlquantum.backends.ionq_backend ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IonQ backend for HLQuantum.
Supports execution on IonQ simulators and trapped-ion QPUs via the
qiskit-ionq provider. When no explicit backend object is supplied
the provider connects to the IonQ cloud simulator.
Prerequisites
~~~~~~~~~~~~~
* pip install qiskit qiskit-ionq
* An IonQ API key, supplied either as the api_key constructor argument
or through the IONQ_API_KEY / QISKIT_IONQ_API_TOKEN environment
variable.
See https://docs.ionq.com and https://github.com/qiskit-partners/qiskit-ionq for full documentation.
IonQBackend
Bases: Backend
Execute HLQuantum circuits on IonQ hardware or simulators.
Parameters
backend_name : str, optional
Name of the IonQ backend to use (default "ionq_simulator").
Common choices:
* ``"ionq_simulator"`` – cloud-based ideal simulator
* ``"ionq_qpu"`` – IonQ Aria / Forte trapped-ion QPU
api_key : str, optional
IonQ API key. Falls back to the IONQ_API_KEY or
QISKIT_IONQ_API_TOKEN environment variables when omitted.
backend : object, optional
A pre-configured Qiskit Backend object. When provided,
backend_name and api_key are ignored.
transpile : bool, optional
Whether to transpile the circuit before execution (default True).
optimization_level : int, optional
Qiskit transpiler optimisation level (0–3, default 1).
Source code in hlquantum/backends/ionq_backend.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
run(circuit, shots=1000, include_statevector=False, **kwargs)
Translate, transpile and execute circuit on the IonQ backend.
Parameters
circuit : QuantumCircuit
The HLQuantum circuit to execute.
shots : int, optional
Number of measurement shots (default 1000).
include_statevector : bool, optional
If True, attempt to retrieve the state vector. Note that
state-vector retrieval is only supported on simulators.
**kwargs
Forwarded to the underlying Qiskit backend.run() call.
Source code in hlquantum/backends/ionq_backend.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |