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.
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
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)
dataclass
Bases:
algo_hevo: AlgoHEvo = AlgoHEvo.EXP
class-attribute
instance-attribute
Determine which kind of Hamiltonian evolution algorithm to use.
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.
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.
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:
|