PyQTorch
Fast differentiable statevector emulator based on PyTorch. The code is open source, hosted on Github and maintained by Pasqal.
Backend(name=BackendName.PYQTORCH, supports_ad=True, support_bp=True, supports_adjoint=True, is_remote=False, with_measurements=True, native_endianness=Endianness.BIG, engine=Engine.TORCH, with_noise=False, config=Configuration())
dataclass
Bases:
PyQTorch backend.
circuit(circuit)
Return the converted circuit.
Note that to get a representation with noise, noise should be passed within the config.
PARAMETER | DESCRIPTION |
---|---|
circuit |
Original circuit
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ConvertedCircuit
|
ConvertedCircuit instance for backend.
TYPE:
|
Source code in qadence/backends/pyqtorch/backend.py
convert(circuit, observable=None)
Convert an abstract circuit and an optional observable to their native representation.
Additionally, this function constructs an embedding function which maps from user-facing parameters to device parameters (read more on parameter embedding here).
Source code in qadence/backend.py
set_block_and_readout_noises(circuit, noise, config)
Add noise on blocks and readout on circuit.
We first start by adding noise to the abstract blocks. Then we do a conversion to their native representation. Finally, we add readout.
PARAMETER | DESCRIPTION |
---|---|
circuit |
Input circuit.
TYPE:
|
noise |
Noise to add.
TYPE:
|
Source code in qadence/backends/pyqtorch/backend.py
set_noise_abstract_to_native(circuit, config)
Set noise in native blocks from the abstract ones with noise.
PARAMETER | DESCRIPTION |
---|---|
circuit |
Input converted circuit.
TYPE:
|
Source code in qadence/backends/pyqtorch/backend.py
set_readout_noise(circuit, noise)
Set readout noise in place in native.
PARAMETER | DESCRIPTION |
---|---|
circuit |
Input converted circuit.
TYPE:
|
noise |
Noise.
TYPE:
|
Source code in qadence/backends/pyqtorch/backend.py
Configuration(_use_gate_params=True, use_sparse_observable=False, use_gradient_checkpointing=False, use_single_qubit_composition=False, transpilation_passes=None, algo_hevo=AlgoHEvo.EXP, ode_solver=SolverType.DP5_SE, n_steps_hevo=100, loop_expectation=False, noise=None, dropout_probability=0.0, dropout_mode=DropoutMode.ROTATIONAL)
dataclass
Bases:
algo_hevo: AlgoHEvo = AlgoHEvo.EXP
class-attribute
instance-attribute
Determine which kind of Hamiltonian evolution algorithm to use.
dropout_mode: DropoutMode = DropoutMode.ROTATIONAL
class-attribute
instance-attribute
Type of quantum dropout to perform.
dropout_probability: float = 0.0
class-attribute
instance-attribute
Quantum dropout probability (0 means no dropout).
loop_expectation: bool = False
class-attribute
instance-attribute
When computing batches of expectation values, only allocate one wavefunction.
Loop over the batch of parameters to only allocate a single wavefunction at any given time.
n_steps_hevo: int = 100
class-attribute
instance-attribute
Default number of steps for the Hamiltonian evolution.
noise: NoiseHandler | None = None
class-attribute
instance-attribute
NoiseHandler containing readout noise applied in backend.
ode_solver: SolverType = SolverType.DP5_SE
class-attribute
instance-attribute
Determine which ODE solver to use for time-dependent blocks.
use_gradient_checkpointing: bool = False
class-attribute
instance-attribute
Use gradient checkpointing.
Recommended for higher-order optimization tasks.
use_single_qubit_composition: bool = False
class-attribute
instance-attribute
Composes chains of single qubit gates into a single matmul if possible.
supported_gates = list(set(OpName.list()) - set([OpName.TDAGGER]))
module-attribute
The set of supported gates.
Tdagger is currently not supported.
convert_block(block, n_qubits=None, config=None)
Convert block to native Pyqtorch representation.
PARAMETER | DESCRIPTION |
---|---|
block |
Block to convert.
TYPE:
|
n_qubits |
Number of qubits. Defaults to None.
TYPE:
|
config |
Backend configuration instance. Defaults to None.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
|
For non supported blocks. |
RETURNS | DESCRIPTION |
---|---|
|
Sequence[Module | Tensor | str | sympy.Expr]: List of native operations. |
Source code in qadence/backends/pyqtorch/convert_ops.py
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 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
|
convert_digital_noise(noise)
Convert the digital noise into pyqtorch NoiseProtocol.
PARAMETER | DESCRIPTION |
---|---|
noise |
Noise to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
|
pyq.noise.NoiseProtocol | None: Pyqtorch native noise protocol if there are any digital noise protocols. |
Source code in qadence/backends/pyqtorch/convert_ops.py
convert_readout_noise(n_qubits, noise)
Convert the readout noise into pyqtorch ReadoutNoise.
PARAMETER | DESCRIPTION |
---|---|
n_qubits |
Number of qubits
TYPE:
|
noise |
Noise to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
|
pyq.noise.ReadoutNoise | None: Pyqtorch native ReadoutNoise instance if readout is is noise. |
Source code in qadence/backends/pyqtorch/convert_ops.py
extract_parameter(block, config)
Extract the parameter as string or its tensor value.
PARAMETER | DESCRIPTION |
---|---|
block |
Block to extract parameter from.
TYPE:
|
config |
Configuration instance.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
|
str | Tensor: Parameter value or symbol. |
Source code in qadence/backends/pyqtorch/convert_ops.py
replace_underscore_floats(s)
Replace underscores with periods for all floats in given string.
Needed for correct parsing of string by sympy parser.
PARAMETER | DESCRIPTION |
---|---|
s |
string expression
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
transformed string expression
TYPE:
|
Source code in qadence/backends/pyqtorch/convert_ops.py
sympy_to_pyq(expr)
Convert sympy expression to pyqtorch ConcretizedCallable object.
PARAMETER | DESCRIPTION |
---|---|
expr |
sympy expression
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ConcretizedCallable
|
expression encoded as ConcretizedCallable
TYPE:
|