Operator Group Module

The operator_group module contains collections of operators for different physical systems.

Base Operator Group

class qepsilon.operator_group.OperatorGroup(id: str, num_states: int, batchsize: int = 1, static: bool = False)[source]

Bases: Module

This is a base class for operator groups.

__init__(id: str, num_states: int, batchsize: int = 1, static: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

reset()[source]

Reset the coefficients of the operator group.

add_operator(prefactor: float = 1.0)[source]

Add an operator (with a prefactor) to the group. Description of the operator is stored in self._ops. To be implemented in subclasses. :param prefactor: float, the prefactor of the operator.

sum_operators()[source]

Sum up the operators in the group. Coefficients not multiplied! To be implemented in subclasses. Returns a matrix of shape (self.ns, self.ns).

clear_buffer()[source]
sample(dt: float = None)[source]

Composed Operator Groups

class qepsilon.operator_group.ComposedOperatorGroups(id: str, OP_list: list[OperatorGroup], static: bool = False)[source]

Bases: OperatorGroup

__init__(id: str, OP_list: list[OperatorGroup], static: bool = False)[source]

Compose multiple operator groups. :param OP_list: a list of operator groups.

Returns:

The composed operator group.

reset()[source]

Reset the coefficients of the operator group.

to(device='cuda')[source]

This overrides the method of PyTorch Module. It is used to move all operator groups in the composed operator group to a specific device.

add_operator(prefactor: float = 1.0)[source]

Add an operator (with a prefactor) to the group. Description of the operator is stored in self._ops. To be implemented in subclasses. :param prefactor: float, the prefactor of the operator.

sum_operators()[source]

Sum up the operators in the group. Coefficients not multiplied! To be implemented in subclasses. Returns a matrix of shape (self.ns, self.ns).

Bosonic Operators

class qepsilon.operator_group.BosonOperatorGroup(num_modes, id: str, nmax: int, batchsize: int = 1, static: bool = False)[source]

Bases: OperatorGroup

__init__(num_modes, id: str, nmax: int, batchsize: int = 1, static: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

add_operator(boson_sequence: str, prefactor: float = 1)[source]

Add an operator to the group. Stored as a string of boson operator names. :param boson_sequence: str, the boson sequence. Example: “+-1” for creation of mode 0, annihilation of mode 1, identity of mode 2.

sum_operators()[source]

Sum up the operators in the group. Coefficients not multiplied! To be implemented in subclasses. Returns a matrix of shape (self.ns, self.ns).

class qepsilon.operator_group.IdentityBosonOperatorGroup(num_modes, id: str, nmax: int, batchsize: int = 1)[source]

Bases: BosonOperatorGroup

__init__(num_modes, id: str, nmax: int, batchsize: int = 1)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

add_operator(boson_sequence: str)[source]

Add an operator to the group. Stored as a string of boson operator names. :param boson_sequence: str, the boson sequence. Example: “+-1” for creation of mode 0, annihilation of mode 1, identity of mode 2.

class qepsilon.operator_group.StaticBosonOperatorGroup(num_modes, id: str, nmax: int, batchsize: int = 1, coef: float = 1.0, static: bool = True, requires_grad: bool = False)[source]

Bases: BosonOperatorGroup

This class deals with a group of operators (composite boson operators on n-mode systems) and a static coefficient. Each operator is a direct product of boson operators. It is specified by a string of boson operator names. For example, “UDI” is the 2-body operator $$a^dagger_0 otimes a_1 otimes I_2$$.

__init__(num_modes, id: str, nmax: int, batchsize: int = 1, coef: float = 1.0, static: bool = True, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class qepsilon.operator_group.HarmonicOscillatorBosonOperatorGroup(num_modes, id: str, nmax: int, batchsize: int, omega: Tensor, requires_grad: bool = False)[source]

Bases: BosonOperatorGroup

static operator H = sum_i omega_i (a_i^dagger a_i + 1/2)

__init__(num_modes, id: str, nmax: int, batchsize: int, omega: Tensor, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

property omega
add_operator(boson_sequence: str)[source]

Add an operator to the group. Stored as a string of boson operator names. :param boson_sequence: str, the boson sequence. Example: “+-1” for creation of mode 0, annihilation of mode 1, identity of mode 2.

sum_operators()[source]

Sum up the operators in the group. Coefficients not multiplied! To be implemented in subclasses. Returns a matrix of shape (self.ns, self.ns).

class qepsilon.operator_group.WhiteNoiseBosonOperatorGroup(num_modes, id: str, nmax: int, batchsize: int = 1, amp: float = 1, requires_grad: bool = False)[source]

Bases: BosonOperatorGroup

This class deals with a group of operators (composite boson operators on n-mode systems) and a white noise coefficient.

__init__(num_modes, id: str, nmax: int, batchsize: int = 1, amp: float = 1, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

property amp
class qepsilon.operator_group.LangevinNoiseBosonOperatorGroup(num_modes, id: str, nmax: int, batchsize: int = 1, tau: float = 1, amp: float = 1, requires_grad: bool = False)[source]

Bases: BosonOperatorGroup

This class deals with a group of operators (composite boson operators on n-mode systems) and a Langevin noise coefficient.

__init__(num_modes, id: str, nmax: int, batchsize: int = 1, tau: float = 1, amp: float = 1, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

property amp
property tau
property damping
reset()[source]

Reset the coefficients of the operator group.

z1(dt: float)[source]
z2(dt: float)[source]
class qepsilon.operator_group.ColorNoiseBosonOperatorGroup(num_modes, id: str, nmax: int, batchsize: int = 1, tau: float = 1, amp: float = 1, omega: float = 1, requires_grad: bool = False)[source]

Bases: LangevinNoiseBosonOperatorGroup

This class deals with a group of operators (composite boson operators on n-mode systems) and a color noise coefficient. The autocorrelation function of the color noise is ~exp(-t/tau)cos(omega*t).

__init__(num_modes, id: str, nmax: int, batchsize: int = 1, tau: float = 1, amp: float = 1, omega: float = 1, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

reset()[source]

Reset the coefficients of the operator group.

Tight-Binding Operators

class qepsilon.operator_group.TightBindingOperatorGroup(n_sites: int, id: str, batchsize: int = 1, static: bool = False)[source]

Bases: OperatorGroup

This class represents a group of composite Tight Binding operators on n-site systems.

Each operator in this group is specified by a string of Tight Binding operator names. For example, “XXLXX” is the hopping operator \(| 1\rangle\langle 2 |\).

__init__(n_sites: int, id: str, batchsize: int = 1, static: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

add_operator(TBSequence: str, prefactor: float = 1)[source]

Add an operator to the group. Stored as a string of Tight Binding operator names. :param TBSequence: str, the Tight Binding sequence. Example: “XXLXX. Contains one and only one non-X character, choosing from L, R, N.

sum_operators()[source]

Sum up the operators in the group. :returns: th.Tensor, the total operator matrix of shape (self.ns, self.ns). :rtype: total_ops

class qepsilon.operator_group.IdentityTightBindingOperatorGroup(n_sites: int, id: str, batchsize: int = 1, static: bool = True)[source]

Bases: TightBindingOperatorGroup

__init__(n_sites: int, id: str, batchsize: int = 1, static: bool = True)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class qepsilon.operator_group.StaticTightBindingOperatorGroup(n_sites: int, id: str, batchsize: int = 1, coef: float = 1, static: bool = True, requires_grad: bool = False)[source]

Bases: TightBindingOperatorGroup

This class deals with a group of operators (composite Tight Binding operators on n-site systems) and a static coefficient. Each operator in this group is specified by a string of Tight Binding operator names. For example, “XXLXX” is the hopping operator \(| 1\rangle\langle 2 |\).

__init__(n_sites: int, id: str, batchsize: int = 1, coef: float = 1, static: bool = True, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class qepsilon.operator_group.PeriodicNoiseTightBindingOperatorGroup(n_sites: int, id: str, batchsize: int = 1, tau: float = 1, amp: float = 1, requires_grad: bool = False)[source]

Bases: TightBindingOperatorGroup

This class deals with a group of operators (composite Tight Binding operators on n-site systems) and a periodic noise.

__init__(n_sites: int, id: str, batchsize: int = 1, tau: float = 1, amp: float = 1, requires_grad: bool = False)[source]
Parameters:
  • tau – float, the period of the noise.

  • amp – float, the amplitude of the noise.

property amp
property tau
reset()[source]

Reset the coefficients of the operator group.

class qepsilon.operator_group.WhiteNoiseTightBindingOperatorGroup(n_sites: int, id: str, batchsize: int = 1, amp: float = 1, requires_grad: bool = False)[source]

Bases: TightBindingOperatorGroup

This class deals with a group of operators (composite Tight Binding operators on n-site systems) and a white noise coefficient.

__init__(n_sites: int, id: str, batchsize: int = 1, amp: float = 1, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

property amp
class qepsilon.operator_group.tb_oscillators_interaction(n_sites: int, id: str, batchsize: int, particles: Particles, coef: Tensor, requires_grad: bool = False)[source]

Bases: TightBindingOperatorGroup

Tight Binding particle-(classical) Oscillator interaction as an approximation to Tight binding particle-boson interaction. For each oscillator, the interaction is coef * x * N, where x is the position of the oscillator, and N is the number operator of the tight binding site.

__init__(n_sites: int, id: str, batchsize: int, particles: Particles, coef: Tensor, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Spin Operators

class qepsilon.operator_group.PauliOperatorGroup(n_qubits: int, id: str, batchsize: int = 1, static: bool = False)[source]

Bases: OperatorGroup

This class deals with a group of operators (composite Pauli operators on n-qubit systems). Each operator is a direct product of Pauli operators. It is specified by a string of Pauli operator names. For example, “XI” is the 2-body operator X_1 otimes I_2.

__init__(n_qubits: int, id: str, batchsize: int = 1, static: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

set_batch_rescaling(batch_rescaling: Tensor)[source]

Set the batch rescaling of the operator group. The final coefficiant will be multiplied by the batch rescaling. :param batch_rescaling: th.Tensor, the batch rescaling of shape (self.nb,).

add_operator(PauliSequence: str, prefactor: float = 1)[source]

Add an operator to the group. Stored as a string of Pauli operator names. :param PauliSequence: str, the Pauli sequence. Example: “XI”

sum_operators()[source]

Sum up the operators in the group. :returns: th.Tensor, the total operator matrix of shape (self.ns, self.ns). :rtype: total_ops

class qepsilon.operator_group.IdentityPauliOperatorGroup(n_qubits: int, id: str, batchsize: int = 1)[source]

Bases: PauliOperatorGroup

__init__(n_qubits: int, id: str, batchsize: int = 1)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class qepsilon.operator_group.StaticPauliOperatorGroup(n_qubits: int, id: str, batchsize: int = 1, coef: float = 1, static: bool = True, requires_grad: bool = False)[source]

Bases: PauliOperatorGroup

This class deals with a group of operators (composite Pauli operators on n-qubit systems) and a static coefficient. Each operator is a direct product of Pauli operators. It is specified by a string of Pauli operator names. For example, “XI” is the 2-body operator X_1 otimes I_2.

__init__(n_qubits: int, id: str, batchsize: int = 1, coef: float = 1, static: bool = True, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class qepsilon.operator_group.ShotbyShotNoisePauliOperatorGroup(n_qubits: int, id: str, batchsize: int = 1, amp: float = 1, shift: float = None, static: bool = False, requires_grad: bool = False)[source]

Bases: PauliOperatorGroup

This class deals with a group of operators (composite Pauli operators on n-qubit systems) and a shot-by-shot noise coefficient.

__init__(n_qubits: int, id: str, batchsize: int = 1, amp: float = 1, shift: float = None, static: bool = False, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

property amp
reset()[source]

Reset the coefficients of the operator group.

class qepsilon.operator_group.WhiteNoisePauliOperatorGroup(n_qubits: int, id: str, batchsize: int = 1, amp: float = 1, requires_grad: bool = False)[source]

Bases: PauliOperatorGroup

This class deals with a group of operators (composite Pauli operators on n-qubit systems) and a white noise coefficient.

__init__(n_qubits: int, id: str, batchsize: int = 1, amp: float = 1, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

property amp
class qepsilon.operator_group.PeriodicNoisePauliOperatorGroup(n_qubits: int, id: str, batchsize: int = 1, tau: float = 1, amp: float = 1, requires_grad: bool = False, requires_grad_tau_only: bool = False, requires_grad_amp_only: bool = False)[source]

Bases: PauliOperatorGroup

This class deals with a group of operators (composite Pauli operators on n-qubit systems) and a periodic noise.

__init__(n_qubits: int, id: str, batchsize: int = 1, tau: float = 1, amp: float = 1, requires_grad: bool = False, requires_grad_tau_only: bool = False, requires_grad_amp_only: bool = False)[source]
Parameters:
  • tau – float, the period of the noise.

  • amp – float, the amplitude of the noise.

property amp
property tau
reset()[source]

Reset the coefficients of the operator group.

class qepsilon.operator_group.LangevinNoisePauliOperatorGroup(n_qubits: int, id: str, batchsize: int = 1, tau: float = 1, amp: float = 1, requires_grad: bool = False)[source]

Bases: PauliOperatorGroup

This class deals with a group of operators (composite Pauli operators on n-qubit systems) and a fluctuating coefficient.

__init__(n_qubits: int, id: str, batchsize: int = 1, tau: float = 1, amp: float = 1, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

property amp
property tau
property damping
reset()[source]

Reset the coefficients of the operator group.

z1(dt: float)[source]
z2(dt: float)[source]
class qepsilon.operator_group.ColorNoisePauliOperatorGroup(n_qubits, id: str, batchsize: int = 1, tau: float = 1, amp: float = 1, omega: float = 1, requires_grad: bool = False)[source]

Bases: LangevinNoisePauliOperatorGroup

This class deals with a group of operators (composite Pauli operators on n-qubit systems) and a color noise coefficient. The autocorrelation function of the color noise is ~exp(-t/tau)cos(omega*t).

__init__(n_qubits, id: str, batchsize: int = 1, tau: float = 1, amp: float = 1, omega: float = 1, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

reset()[source]

Reset the coefficients of the operator group.

class qepsilon.operator_group.DipolarInteraction(n_qubits: int, id: str, batchsize: int, particles: Particles, connectivity: Tensor, prefactor: float = 1, average_nsteps: int = 100, qaxis: Tensor = tensor([0., 1., 0.]), requires_grad: bool = False)[source]

Bases: PauliOperatorGroup

This class deals with dipolar-dipole interactions.

__init__(n_qubits: int, id: str, batchsize: int, particles: Particles, connectivity: Tensor, prefactor: float = 1, average_nsteps: int = 100, qaxis: Tensor = tensor([0., 1., 0.]), requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

add_operator(prefactor: float = 1)[source]

Add an operator to the group. Stored as a string of Pauli operator names. :param PauliSequence: str, the Pauli sequence. Example: “XI”

sum_operators()[source]

Sum up the operators in the group. :returns: th.Tensor, the total operator matrix of shape (self.ns, self.ns). :rtype: total_ops

get_dipole_dipole_coef()[source]

Get the dipole-dipole interaction coefficients. :returns: th.Tensor, the dipole-dipole interaction coefficients of shape (nb, npair). :rtype: coef

class qepsilon.operator_group.spin_oscillators_interaction(n_qubits: int, id: str, batchsize: int, particles: Particles, coef: Tensor, requires_grad: bool = False)[source]

Bases: PauliOperatorGroup

Spin-(classical) Oscillator interaction as an approximation to spin-boson interaction. For each oscillator, the interaction is coef * x * N, where x is the position of the oscillator, and N is the number operator of the qubit (1 for spin-up, 0 for spin-down).

__init__(n_qubits: int, id: str, batchsize: int, particles: Particles, coef: Tensor, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class qepsilon.operator_group.DepolarizationChannel(n_qubits: int, id: str, batchsize: int, p: float, requires_grad: bool = False)[source]

Bases: PauliOperatorGroup

This class deals with a group of Kraus operators.

__init__(n_qubits: int, id: str, batchsize: int, p: float, requires_grad: bool = False)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

property p
add_operator(prefactor: float = 1)[source]

Add an operator to the group. Stored as a string of Pauli operator names. :param PauliSequence: str, the Pauli sequence. Example: “XI”

sum_operators()[source]

Sum up the operators in the group. :returns: th.Tensor, the total operator matrix of shape (self.ns, self.ns). :rtype: total_ops