Factories

The gate factories generate noisy quantum gates stochastically and return them as as numpy matrices.

Theory

The two main factors that influence the distribution of noisy gates are the following. First, the device parameters for a specific quantum device, containing information such as the T1, T2 times. Second, the pulse shape used to execute a specific gate. While the pulse shape is independent of the qubit we act on, the device parameters are qubit specific. Thus, we choose to add the pulse shape as attribute of the gate factory, while the specific noise parameters are provided as method arguments when creating a gate.

Usage

The are two types of classes, namely the ones representing pure noise and the ones representing the noisy gates. The former do not need the pulse as argument, as they do not come from the execution of a gate, and thus the pulse does not matter.

from quantum_gates.factories import (
    BitflipFactory,
    DepolarizingFactory,
    RelaxationFactory
)

bitflip_factory = BitflipFactory()

tm = ...    # measurement time in ns
rout = ...  # readout error
bitflip_gate = bitflip_factory.construct(tm, rout)

In the latter, we specify the pulse shape used in the execution of the gates.

from quantum_gates.factories import (
    SingleQubitGateFactory,
    XFactory,
    SXFactory,
    CRFactory,
    CNOTFactory,
    CNOTInvFactory
)
from quantum_gates.pulses import GaussianPulse

pulse = GaussianPulse(loc=0.5, scale=0.5)
x_factory = XFactory(pulse)

phi = ...   # Phase of the drive defining axis of rotation on the Bloch sphere
p = ...     # Single-qubit depolarizing error probability
T1 = ...    # Qubit's amplitude damping time in ns
T2 = ...    # Qubit's dephasing time in ns
x_gate = x_factory.construct(phi, p, T1, T2)

Classes

class quantum_gates.factories.BitflipFactory[source]

Bases: object

construct(tm, rout) array[source]

Generates the noisy gate for bitflips.

This is the exact solution, a unitary matrix. It is used for bitflip error on measurements.

Parameters:
  • tm (float) – Measurement time in ns.

  • rout (float) – Readout error probability.

Returns:

Array representing the bitflip noise gate.

Return type:

array

class quantum_gates.factories.DepolarizingFactory[source]

Bases: object

construct(Dt, p) array[source]

Generates the noisy gate for depolarization.

This is the 2nd order approximated solution, a unitary matrix. It implements the single-qubit depolarizing error on idle qubits.

Parameters:
  • Dt (float) – Idle time in ns.

  • p (float) – Single-qubit depolarizing error probability.

Returns:

Array representing the depolarizing noise gate.

Return type:

array

class quantum_gates.factories.RelaxationFactory[source]

Bases: object

construct(Dt, T1, T2) array[source]

Generates the noisy gate for combined amplitude and phase damping.

This is the exact solution, a non-unitary matrix. It implements the single-qubit relaxation error on idle qubits.

Parameters:
  • Dt (float) – idle time in ns.

  • T1 (float) – qubit’s amplitude damping time in ns.

  • T2 (float) – qubit’s dephasing time in ns.

Returns:

Array representing the amplitude and phase damping noise gate.

Return type:

array

class quantum_gates.factories.SingleQubitGateFactory(integrator: Integrator)[source]

Bases: object

Generates a general single qubit gate on devices from IBM with noise.

This is the 2 order approximated solution, a non-unitary matrix.

Parameters:

integrator (Integrator) – Used to perform the Ito integrals, hides the pulse waveform information.

Note

The pulse shape / parametrization is hidden in the integrator, such that we can use caching of integration result to speedup the code.

integrator[source]

Used to perform the Ito integrals, hides the pulse waveform information.

Type:

Integrator

construct(theta, phi, p, T1, T2) array[source]

Samples a general single qubit gate on devices from IBM with noise.

Parameters:
  • theta (float) – Angle of rotation on the Bloch sphere.

  • phi (float) – Phase of the drive defining axis of rotation on the Bloch sphere.

  • p (float) – Single-qubit depolarizing error probability.

  • T1 (float) – Qubit’s amplitude damping time in ns.

  • T2 (float) – Qubit’s dephasing time in ns.

Returns:

Array representing a general single-qubit noisy quantum gate.

Return type:

array

_unitary_contribution(theta, phi) array[source]

Unitary contribution due to drive Hamiltonian.

Parameters:
  • theta (float) – Angle of rotation on the Bloch sphere.

  • phi (float) – Phase of the drive defining axis of rotation on the Bloch sphere.

Returns:

Array representing the unitary contribution due to drive Hamiltonian.

Return type:

array

_ito_integrals_for_X_Y_sigma_min(theta) tuple[float][source]

Ito integrals.

Ito integrals for the following processes:
  • depolarization for X(t)

  • depolarization for Y(t)

  • relaxation for sigma_min(t).

As illustration, we leave the variables names for X(t) in the calculation.

Parameters:

theta (float) – Angle of rotation on the Bloch sphere.

Returns:

Tuple of floats representing sampled results of the Ito integrals.

Return type:

tuple[float]

_ito_integrals_for_Z(theta) tuple[float][source]

Ito integrals.

Ito integrals for the following processes:
  • depolarization for Z(t)

  • relaxation for Z(t).

As illustration, we leave the variable names for the depolarization Itô processes depending on Z(t).

Parameters:

theta (float) – angle of rotation on the Bloch sphere.

Returns:

Tuple of floats representing sampled results of the Ito integrals.

Return type:

tuple[float]

_deterministic_relaxation(theta)[source]

Deterministic contribution given by relaxation

Parameters:

theta (float) – angle of rotation on the Bloch sphere.

Returns:

Array representing the deterministic part of the relaxation process.

class quantum_gates.factories.XFactory(integrator: Integrator)[source]

Bases: object

Factory for the X gate.

Parameters:

integrator (Integrator) – Used to perform the Ito integrals, hides the pulse waveform information.

Note

The dependence on the pulse is hidden in the integrator.

integrator[source]

Used to perform the Ito integrals, hides the pulse waveform information.

Type:

Integrator

constructor[source]

Instance of the gate factory for general single qubit gates.

Type:

SingleQubitGateFactory

construct(phi, p, T1, T2) array[source]

Generates a noisy X gate.

This is a 2nd order approximated solution, a non-unitary matrix. It implements the X single-qubit noisy quantum gate with depolarizing and relaxation errors during the unitary evolution.

Parameters:
  • phi (float) – Phase of the drive defining axis of rotation on the Bloch sphere.

  • p (float) – Single-qubit depolarizing error probability.

  • T1 (float) – Qubit’s amplitude damping time in ns.

  • T2 (float) – Qubit’s dephasing time in ns.

Returns:

Array representing the X noisy quantum gate.

Return type:

array

class quantum_gates.factories.SXFactory(integrator: Integrator)[source]

Bases: object

Factory for the SX gate.

Parameters:

integrator (Integrator) – Used to perform the Ito integrals, hides the pulse waveform information.

Note

The dependence on the pulse is hidden in the integrator.

integrator[source]

Used to perform the Ito integrals, hides the pulse waveform information.

Type:

Integrator

constructor[source]

Instance of the gate factory for general single qubit gates.

Type:

SingleQubitGateFactory

construct(phi, p, T1, T2) array[source]

Generates a noisy SX gate.

This is a 2nd order approximated solution, a non-unitary matrix. It implements the SX single-qubit noisy quantum gate with depolarizing and relaxation errors during the unitary evolution.

Parameters:
  • phi (float) – Phase of the drive defining axis of rotation on the Bloch sphere.

  • p (float) – Single-qubit depolarizing error probability.

  • T1 (float) – Qubit’s amplitude damping time in ns.

  • T2 (float) – Qubit’s dephasing time in ns.

Returns:

Array representing the SX noisy quantum gate.

Return type:

array

class quantum_gates.factories.CRFactory(integrator)[source]

Bases: object

Factory for constructing the noisy quantum gate for cross resonance (CR) two-qubit gate of IBM’s devices.

This is the 2 order approximated solution, non-unitary matrix.

construct(theta, phi, t_cr, p_cr, T1_ctr, T2_ctr, T1_trg, T2_trg) array[source]

Generates a CR gate.

This is the 2 order approximated solution, non-unitary matrix. It implements the CR two-qubit noisy quantum gate with depolarizing and relaxation errors on both qubits during the unitary evolution.

Parameters:
  • theta (float) – Angle of rotation on the Bloch sphere.

  • phi (float) – Phase of the drive defining axis of rotation on the Bloch sphere.

  • t_cr (float) – CR gate time in ns.

  • p_cr (float) – CR depolarizing error probability.

  • T1_ctr (float) – Control qubit’s amplitude damping time in ns.

  • T2_ctr (float) – Control qubit’s dephasing time in ns.

  • T1_trg (float) – Target qubit’s amplitude damping time in ns.

  • T2_trg (float) – Target qubit’s dephasing time in ns.

Returns:

CR two-qubit noisy quantum gate (numpy array)

Return type:

array

_ito_integrals_for_depolarization_process(omega, phi, a) tuple[float][source]

Ito integrals.

Used for the depolarization Itô processes depending on one of
  • [tensor(ID,Z)](t)

  • [tensor(X,ID)](t)

  • [tensor(Y,ID)](t)

  • [tensor(sigma_min,ID)](t)

As illustration, we leave the variable names from the version with [tensor(ID,Z)](t).

Parameters:
  • omega – integral of theta from t0 to t1.

  • phi – phase of the drive defining axis of rotation on the Bloch sphere.

  • a – fraction representing CR gate time / gate time.

Returns:

Tuple of floats representing sampled results of the Ito integrals.

Return type:

tuple[float]

_ito_integrals_for_depolarization_process_reversed_tensor(omega, a) tuple[float][source]

Ito integrals.

Used for the depolarization Itô processes depending on one of
  • [tensor(ID,X)](t)

  • [tensor(ID,Y)](t)

As illustration, we leave the variable names from the version with [tensor(ID,Y)](t).

Parameters:
  • omega (float) – Integral of theta from t0 to t1.

  • a (float) – Fraction representing CR gate time / gate time.

Returns:

Tuple of floats representing sampled results of the Ito integrals.

Return type:

tuple[float]

class quantum_gates.factories.CNOTFactory(integrator)[source]

Bases: object

Factory for constructing noisy CNOT gates.

Parameters:

integrator (Integrator) – Used to perform the Ito integrals, hides the pulse waveform information.

integrator[source]

Used to perform the Ito integrals, hides the pulse waveform information.

Type:

Integrator

cr_c[source]

Instance of the factory for creating CR gates.

Type:

CRFactory

single_qubit_gate_c[source]

Instance of the factory for creating general single qubit gates.

Type:

SingelQubitGateFactory

x_c[source]

Instance of the factory for creating X gates.

Type:

XFactory

sx_c[source]

Instance of the factory for creating SX gates.

Type:

XFactory

relaxation_c[source]

Instance of the factory for creating gates for relaxation.

Type:

RelaxationFactory

construct(phi_ctr, phi_trg, t_cnot, p_cnot, p_single_ctr, p_single_trg, T1_ctr, T2_ctr, T1_trg, T2_trg) array[source]

Generates a noisy CNOT gate.

This is a 2nd order approximated solution, a non-unitary matrix. It implements the CNOT two-qubit noisy quantum gate with depolarizing and relaxation errors on both qubits during the unitary evolution.

Parameters:
  • phi_ctr (float) – Control qubit phase of the drive defining axis of rotation on the Bloch sphere.

  • phi_trg (float) – Target qubit phase of the drive defining axis of rotation on the Bloch sphere.

  • t_cnot (float) – CNOT gate time in ns.

  • p_cnot (float) – CNOT depolarizing error probability.

  • p_single_ctr (float) – Control qubit depolarizing error probability.

  • p_single_trg (float) – Target qubit depolarizing error probability.

  • T1_ctr (float) – Control qubit’s amplitude damping time in ns.

  • T2_ctr (float) – Control qubit’s dephasing time in ns.

  • T1_trg (float) – Target qubit’s amplitude damping time in ns.

  • T2_trg (float) – Target qubit’s dephasing time in ns.

  • pulse_parametrization (callable) – None or function that parametrized the pulse (None or callable)

Returns:

Array representing a CNOT two-qubit noisy quantum gate.

Return type:

array

class quantum_gates.factories.CNOTInvFactory(integrator)[source]

Bases: object

Factory for constructing noisy inverse CNOT gates.

Parameters:

integrator (Integrator) – Used to perform the Ito integrals, hides the pulse waveform information.

integrator[source]

Used to perform the Ito integrals, hides the pulse waveform information.

Type:

Integrator

cr_c[source]

Instance of the factory for creating CR gates.

Type:

CRFactory

single_qubit_gate_c[source]

Instance of the factory for creating general single qubit gates.

Type:

SingelQubitGateFactory

x_c[source]

Instance of the factory for creating X gates.

Type:

XFactory

sx_c[source]

Instance of the factory for creating SX gates.

Type:

XFactory

relaxation_c[source]

Instance of the factory for creating gates for relaxation.

Type:

RelaxationFactory

construct(phi_ctr, phi_trg, t_cnot, p_cnot, p_single_ctr, p_single_trg, T1_ctr, T2_ctr, T1_trg, T2_trg) array[source]

Generates a reverse CNOT gate of IBM devices.

This is a 2nd order approximated solution, a non-unitary matrix. It implements the reverse CNOT two-qubit noisy quantum gate with depolarizing and relaxation errors on both qubits during the unitary evolution.

Parameters:
  • phi_ctr (float) – control qubit phase of the drive defining axis of rotation on the Bloch sphere.

  • phi_trg (float) – target qubit phase of the drive defining axis of rotation on the Bloch sphere.

  • t_cnot (float) – reverse CNOT gate time in ns.

  • p_cnot (float) – reverse CNOT depolarizing error probability.

  • p_single_ctr (float) – control qubit depolarizing error probability.

  • p_single_trg (float) – target qubit depolarizing error probability.

  • T1_ctr (float) – control qubit’s amplitude damping time in ns.

  • T2_ctr (float) – control qubit’s dephasing time in ns.

  • T1_trg (float) – target qubit’s amplitude damping time in ns.

  • T2_trg (float) – target qubit’s dephasing time in ns.

  • pulse_parametrization (callable) – None or function that parametrized the pulse.

Returns:

Array representing the reverse CNOT two-qubit noisy quantum gate.

Return type:

array