qpd#

Quasiprobability-decomposition gates

Classes

DoubleGateQPD(bases, coeffs[, label, name, ...])

A base class for two-qubit QPD gates.

MoveQPD([nqubit, wires, label, den_mat, ...])

QPD representation of the move operation.

SingleGateQPD(bases, coeffs[, label, name, ...])

A base class for single-qubit QPD gates.

class DoubleGateQPD(bases: nn.ModuleList[nn.ModuleList[nn.Sequential]], coeffs: list[float], label: int | None = None, name: str | None = None, nqubit: int = 2, wires: list[int] | None = None, den_mat: bool = False, tsr_mode: bool = False)[source]#

Bases: GateQPD

A base class for two-qubit QPD gates.

Parameters:
  • bases (nn.ModuleList[nn.ModuleList[nn.Sequential]]) – The probabilistic basis operations for the decomposition. A nested structure where: - bases[i] is the i-th term of the QPD (corresponding to coeffs[i]). - bases[i][j] is the nn.Sequential operations applied to the j-th qubit.

  • coeffs (list[float]) – The coefficients for quasiprobability representation.

  • label (int | None) – The label of the gate. Default: None

  • name (str | None) – The name of the quantum operation. Default: None

  • nqubit (int) – The number of qubits that the quantum operation acts on. Default: 2

  • wires (list[int] | None) – The indices of the qubits that the quantum operation acts on. Default: None

  • den_mat (bool) – Whether the quantum operation acts on density matrices or state vectors. Default: False (which means state vectors)

  • tsr_mode (bool) – Whether the quantum operation is in tensor mode, which means the input and output are represented by a tensor of shape \((\text{batch}, 2, ..., 2)\). Default: False

decompose() tuple[SingleGateQPD, SingleGateQPD][source]#

Decompose the gate into two single-qubit QPD gates.

class MoveQPD(nqubit: int = 2, wires: list[int] | None = None, label: int | None = None, den_mat: bool = False, tsr_mode: bool = False)[source]#

Bases: DoubleGateQPD

QPD representation of the move operation.

Parameters:
  • nqubit (int) – The number of qubits that the quantum operation acts on. Default: 2

  • wires (list[int] | None) – The indices of the qubits that the quantum operation acts on. Default: None

  • label (int | None) – The label of the gate. Default: None

  • den_mat (bool) – Whether the quantum operation acts on density matrices or state vectors. Default: False (which means state vectors)

  • tsr_mode (bool) – Whether the quantum operation is in tensor mode, which means the input and output are represented by a tensor of shape \((\text{batch}, 2, ..., 2)\). Default: False

class SingleGateQPD(bases: nn.ModuleList[nn.ModuleList[nn.Sequential]], coeffs: list[float], label: int | None = None, name: str | None = None, nqubit: int = 1, wires: list[int] | None = None, den_mat: bool = False, tsr_mode: bool = False)[source]#

Bases: GateQPD

A base class for single-qubit QPD gates.

Parameters:
  • bases (nn.ModuleList[nn.ModuleList[nn.Sequential]]) – The probabilistic basis operations for the decomposition. A nested structure where: - bases[i] is the i-th term of the QPD (corresponding to coeffs[i]). - bases[i][j] is the nn.Sequential operations applied to the j-th qubit.

  • coeffs (list[float]) – The coefficients for quasiprobability representation.

  • label (int | None) – The label of the gate. Default: None

  • name (str | None) – The name of the quantum operation. Default: None

  • nqubit (int) – The number of qubits that the quantum operation acts on. Default: 1

  • wires (list[int] | None) – The indices of the qubits that the quantum operation acts on. Default: None

  • den_mat (bool) – Whether the quantum operation acts on density matrices or state vectors. Default: False (which means state vectors)

  • tsr_mode (bool) – Whether the quantum operation is in tensor mode, which means the input and output are represented by a tensor of shape \((\text{batch}, 2, ..., 2)\). Default: False