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
- class quantum_gates.factories.DepolarizingFactory[source]
Bases:
object
- class quantum_gates.factories.RelaxationFactory[source]
Bases:
object
- 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.
- construct(theta, phi, p, T1, T2) array [source]
Samples a general single qubit gate on devices from IBM with noise.
- Parameters:
- Returns:
Array representing a general single-qubit noisy quantum gate.
- 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.
- 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.
- 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:
- 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.
- 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:
- 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).
- 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.
- single_qubit_gate_c[source]
Instance of the factory for creating general single qubit gates.
- Type:
SingelQubitGateFactory
- 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.
- single_qubit_gate_c[source]
Instance of the factory for creating general single qubit gates.
- Type:
SingelQubitGateFactory
- 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