topqad_sdk.noiseprofiler.libnoise package

Submodules

topqad_sdk.noiseprofiler.libnoise.models module

class topqad_sdk.noiseprofiler.libnoise.models.NoiseModelName(value)[source]

Bases: str, Enum

PHYSICAL_DEPOLARIZING = 'physical_depolarizing'
UNIFORM_DEPOLARIZING = 'uniform_depolarizing'
class topqad_sdk.noiseprofiler.libnoise.models.NoiseModelSpecificationModel(*, label: str | float | tuple[str, float], noise_model_name: NoiseModelName, parameters: NoiseModelParameters_PhysicalDepolarizing | NoiseModelParameters_UniformDepolarizing)[source]

Bases: BaseModel

classmethod convert_label_list_to_tuple(v)[source]
label: str | float | tuple[str, float]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

noise_model_name: NoiseModelName
parameters: NoiseModelParameters_PhysicalDepolarizing | NoiseModelParameters_UniformDepolarizing
classmethod validate_parameters(values)[source]

topqad_sdk.noiseprofiler.libnoise.noisemodel module

The base noise model class.

class topqad_sdk.noiseprofiler.libnoise.noisemodel.NoiseModel[source]

Bases: object

class topqad_sdk.noiseprofiler.libnoise.noisemodel.NoiseModelParameters[source]

Bases: BaseModel

Base class for noise model parameters.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class topqad_sdk.noiseprofiler.libnoise.noisemodel.Quantity(*, value: float, unit: str)[source]

Bases: BaseModel

A basic quantity with a value and unit.

classmethod from_raw_value(raw_value: float, unit: str) Quantity[source]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

unit: str
value: float

topqad_sdk.noiseprofiler.libnoise.physical_depolarizing module

class topqad_sdk.noiseprofiler.libnoise.physical_depolarizing.NoiseModelParameters_PhysicalDepolarizing(*, preparation_error: Quantity, reset_error: Quantity, measurement_error: Quantity, one_qubit_gate_error: Quantity, two_qubit_gate_error: Quantity, T1_longitudinal_relaxation_time: Quantity, T2_transverse_relaxation_time: Quantity, preparation_time: Quantity, reset_time: Quantity, measurement_time: Quantity, one_qubit_gate_time: Quantity, two_qubit_gate_time: Quantity)[source]

Bases: NoiseModelParameters

T1_longitudinal_relaxation_time: Quantity
T2_transverse_relaxation_time: Quantity
check_T1_T2_relation()[source]
classmethod is_error(param: Quantity) Quantity[source]
classmethod is_time(param: Quantity) Quantity[source]
measurement_error: Quantity
measurement_time: Quantity
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

one_qubit_gate_error: Quantity
one_qubit_gate_time: Quantity
preparation_error: Quantity
preparation_time: Quantity
reset_error: Quantity
reset_time: Quantity
two_qubit_gate_error: Quantity
two_qubit_gate_time: Quantity
classmethod validate_one_qubit_gate_error(one_qubit_gate_error: Quantity) Quantity[source]
classmethod validate_two_qubit_gate_error(two_qubit_gate_error: Quantity) Quantity[source]
class topqad_sdk.noiseprofiler.libnoise.physical_depolarizing.PhysicalDepolarizing(*, preparation_error: Quantity, reset_error: Quantity, measurement_error: Quantity, one_qubit_gate_error: Quantity, two_qubit_gate_error: Quantity, T1_longitudinal_relaxation_time: Quantity, T2_transverse_relaxation_time: Quantity, preparation_time: Quantity, reset_time: Quantity, measurement_time: Quantity, one_qubit_gate_time: Quantity, two_qubit_gate_time: Quantity, noise_channel_prescription: str = 'circuit')[source]

Bases: NoiseModel

A physical depolarizing noise model, based on the model described in Appendix E of Ref. [1]_.

It consists of three types of errors: gate errors, idling errors, and state preparation and measurement (SPAM) errors.

Gate Errors

Imperfect gates are modelled by adding a depolarizing noise channel at rate $p$ to the gate qubits after the application of each gate, where the parameterization assumes that $1 - p$ is the probability of leaving the input state unaltered.

The rate $p$ is determined by utilizing the formula for the depolarizing channel’s average gate fidelity, $$ F_{text{dep}, n} = 1 - frac{(2^n - 1) 2^n}{2^{2n} - 1} p, $$ where $n$ is the number of gate qubits.

Idling Errors

Any qubit that is idling experiences an error, dependent on both the $T_1$ (longitudinal relaxation time) and the $T_2$ (transverse relaxation time) of the qubit, as well as the time $t$ it takes to apply the gate(s) to the active qubits.

The error is modelled with a one-qubit stochastic Pauli noise channel defined by the parameter vector $$ (p_x, p_y, p_z) = left(frac{1}{4} (1 - e^{-t/T_1}), frac{1}{4} (1 - e^{-t/T_1}), frac{1}{4} (1 + e^{-t/T_1} - 2 e^{-t/T_2})right), $$ where $p_x, p_y, p_z$ are the probabilities of $X, Y, Z$ errors, respectively.

SPAM Errors

The errors in state preparation and reset are captured by assuming that, with rate $p$, the orthogonal state is produced, that is, $|0rangle$ is prepared instead of $|1rangle$ and vice versa. Similarly, measurements in the $Z$ basis are flipped at rate $p$. In all three cases, the fidelity of the operation is $$ F_{text{SPAM}} = frac{P(0|0) + P(1|1)}{2}, $$ from which we directly determine the rate $p = 1 - F_{text{SPAM}}$.

References

calculate_stabilization_time(unit='μs')[source]

Calculate the stabilization time.

Parameters:

unit (str) – An acceptable unit of time.

Returns:

stabilization time.

Return type:

Quantity

classmethod from_dict(noise_parameter_dictionary: dict[str, dict[str, float | str]], noise_channel_prescription: str = 'circuit') PhysicalDepolarizing[source]

Create noise model from a dictionary of parameters.

Parameters:
  • noise_parameter_dictionary (dict[str, dict[str, Union[float, str]]]) – The dictionary of parameters. Each key should be a parameter, and the value itself a dictionary with two keys: ‘value’ and ‘unit’. For unitless quantities set ‘unit’ to ‘’.

  • noise_channel_prescription (str, optional) – Name of prescription. Current option are [‘circuit’]. Defaults to ‘circuit’.

Returns:

The noise model.

Return type:

PhysicalDepolarizing

classmethod from_preset(parameter_set_name: str, noise_channel_prescription: str = 'circuit') PhysicalDepolarizing[source]

Create noise model from inbuilt sets of parameters.

Parameters:
  • parameter_set_name (str) – One of “baseline”, “target”, “desired”, which are parameters sets from Ref. [1].

  • noise_channel_prescription (str, optional) – Name of prescription. Current option are [‘circuit’]. Defaults to ‘circuit’.

Returns:

The noise model.

Return type:

PhysicalDepolarizing

noise_model_name = 'physical_depolarizing'
static strength_gate_operation_noise_channel(F: float, n: int) float[source]

Calculate the strength p of a depolarizing noise channel whose average gate fidelity is F.

The channel parameterization assumes that (1-p) is the probability of leaving the input state unaltered.

Parameters:
  • F (float) – Average gate fidelity.

  • n (float) – number of gate qubits.

static strength_idle_qubit_noise_channel(T1_longitudinal_relaxation_time: float, t: float) float[source]

Calculate the strength p of a single qubit depolarizing noise channel on an idle qubit.

This is equivalent to the decay/dephasing channel with the thermal equilibrium state alpha_0 = 1/2 (see Eq. (7.144) of Ref. [1]). The physical meaning of alpha_0 = 1/2 is that it corresponds to the limit where the equilibrium temperature is infinite. The depolarizing channel parameterization assumes that (1 - p) is the probability of leaving the input state unaltered. It is assumed that the T2 (dephasing time) is equal to the T1 (relaxation time).

[1] M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed (Cambridge University Press, 2010).

Parameters:
  • T1_relaxation_time (float) – The T1 of a qubit.

  • t (float) – The idling duration of the qubit.

static strength_idle_qubit_stochastic_noise_channel(T1_longitudinal_relaxation_time: float, T2_transverse_relaxation_time: float, t: float) tuple[float, float, float][source]

Calculate the strength p of a single qubit stochastic Pauli noise channel on an idle qubit.

This is equivalent to the decay/dephasing channel with the thermal equilibrium state alpha_0 = 1/2 (see Eq. (7.144) of Ref. [1]). The physical meaning of alpha_0 = 1/2 is that it corresponds to the limit where the equilibrium temperature is infinite. The stochastic Pauli channel parameterization assumes that (1 - px - py - pz) is the probability of leaving the input state unaltered.

[1] M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed (Cambridge University Press, 2010).

Parameters:
  • T1_longitudinal_relaxation_time (float) – The T1 of a qubit.

  • T2_transverse_relaxation_time (float) – The T2 of a qubit.

  • t (float) – The idling duration of the qubit.

static strength_spam_operation_noise_channel(F: float) float[source]

Calculate the strength p of a Pauli X noise channel whose average fidelity is F.

F is assumed to be:

F = 1 - (P(1|0) + P(0|1))/2

i.e. one minus the average probability that the desired/prepared state has indeed been prepared/measured. The channel parameterization assumes that (1-p_x) is the probability of leaving the input state unaltered, and p_x is the probability that X error has been applied.

Parameters:

F (float) – Fidelity of the SPAM operation.

topqad_sdk.noiseprofiler.libnoise.uniform_depolarizing module

class topqad_sdk.noiseprofiler.libnoise.uniform_depolarizing.NoiseModelParameters_UniformDepolarizing(*, p: float, stabilization_time: Quantity)[source]

Bases: NoiseModelParameters

classmethod is_probability(p: float) float[source]
classmethod is_time(param: Quantity) Quantity[source]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

p: float
stabilization_time: Quantity
class topqad_sdk.noiseprofiler.libnoise.uniform_depolarizing.UniformDepolarizing(*, p: float, stabilization_time: Quantity = Quantity(value=1.0, unit='μs'), noise_channel_prescription: str = 'circuit')[source]

Bases: NoiseModel

A simple uniform depolarizing noise model, in which all noise channels have the same strength $p$. The noise channels added before or after every circuit operations are as follows.

  • Preparation and reset are followed by bit or phase flip errors, depending on the basis.

  • Measurements are noisy with probability $p$ of error, and are followed by a one-qubit depolarizing noise channel.

  • One-qubit gates are followed by a one-qubit depolarizing noise channel.

  • Two-qubit gates are followed by a two-qubit depolarizing noise channel.

  • Idle qubits experience a one-qubit depolarizing noise channel at each tick.

This model was inspired by the model described in Appendix A of Ref. [1].

### References

[1] C. Gidney, N. Shutty, and C. Jones, Magic State Cultivation: Growing T States as Cheap as CNOT Gates, (2024)

arXiv:2409.17595.

calculate_stabilization_time(unit='μs')[source]

Calculate the stabilization time.

Parameters:

unit (str) – An acceptable unit of time.

Returns:

stabilization time.

Return type:

Quantity

classmethod from_dict(noise_parameter_dictionary: dict[str, float], noise_channel_prescription: str = 'circuit')[source]

Create noise model from a dictionary of parameters.

Parameters:
  • noise_parameter_dictionary (dict[str, float]) – The dictionary of parameters. Dictionary is of the form {“p”: 0.01}.

  • noise_channel_prescription (str, optional) – Name of prescription. Current option are [‘circuit’]. Defaults to ‘circuit’.

noise_model_name = 'uniform_depolarizing'

Module contents

The available noise models are

  1. PhysicalDepolarizing

  2. UniformDepolarizing

class topqad_sdk.noiseprofiler.libnoise.NoiseModel[source]

Bases: object

class topqad_sdk.noiseprofiler.libnoise.PhysicalDepolarizing(*, preparation_error: Quantity, reset_error: Quantity, measurement_error: Quantity, one_qubit_gate_error: Quantity, two_qubit_gate_error: Quantity, T1_longitudinal_relaxation_time: Quantity, T2_transverse_relaxation_time: Quantity, preparation_time: Quantity, reset_time: Quantity, measurement_time: Quantity, one_qubit_gate_time: Quantity, two_qubit_gate_time: Quantity, noise_channel_prescription: str = 'circuit')[source]

Bases: NoiseModel

A physical depolarizing noise model, based on the model described in Appendix E of Ref. [1]_.

It consists of three types of errors: gate errors, idling errors, and state preparation and measurement (SPAM) errors.

Gate Errors

Imperfect gates are modelled by adding a depolarizing noise channel at rate $p$ to the gate qubits after the application of each gate, where the parameterization assumes that $1 - p$ is the probability of leaving the input state unaltered.

The rate $p$ is determined by utilizing the formula for the depolarizing channel’s average gate fidelity, $$ F_{text{dep}, n} = 1 - frac{(2^n - 1) 2^n}{2^{2n} - 1} p, $$ where $n$ is the number of gate qubits.

Idling Errors

Any qubit that is idling experiences an error, dependent on both the $T_1$ (longitudinal relaxation time) and the $T_2$ (transverse relaxation time) of the qubit, as well as the time $t$ it takes to apply the gate(s) to the active qubits.

The error is modelled with a one-qubit stochastic Pauli noise channel defined by the parameter vector $$ (p_x, p_y, p_z) = left(frac{1}{4} (1 - e^{-t/T_1}), frac{1}{4} (1 - e^{-t/T_1}), frac{1}{4} (1 + e^{-t/T_1} - 2 e^{-t/T_2})right), $$ where $p_x, p_y, p_z$ are the probabilities of $X, Y, Z$ errors, respectively.

SPAM Errors

The errors in state preparation and reset are captured by assuming that, with rate $p$, the orthogonal state is produced, that is, $|0rangle$ is prepared instead of $|1rangle$ and vice versa. Similarly, measurements in the $Z$ basis are flipped at rate $p$. In all three cases, the fidelity of the operation is $$ F_{text{SPAM}} = frac{P(0|0) + P(1|1)}{2}, $$ from which we directly determine the rate $p = 1 - F_{text{SPAM}}$.

References

calculate_stabilization_time(unit='μs')[source]

Calculate the stabilization time.

Parameters:

unit (str) – An acceptable unit of time.

Returns:

stabilization time.

Return type:

Quantity

classmethod from_dict(noise_parameter_dictionary: dict[str, dict[str, float | str]], noise_channel_prescription: str = 'circuit') PhysicalDepolarizing[source]

Create noise model from a dictionary of parameters.

Parameters:
  • noise_parameter_dictionary (dict[str, dict[str, Union[float, str]]]) – The dictionary of parameters. Each key should be a parameter, and the value itself a dictionary with two keys: ‘value’ and ‘unit’. For unitless quantities set ‘unit’ to ‘’.

  • noise_channel_prescription (str, optional) – Name of prescription. Current option are [‘circuit’]. Defaults to ‘circuit’.

Returns:

The noise model.

Return type:

PhysicalDepolarizing

classmethod from_preset(parameter_set_name: str, noise_channel_prescription: str = 'circuit') PhysicalDepolarizing[source]

Create noise model from inbuilt sets of parameters.

Parameters:
  • parameter_set_name (str) – One of “baseline”, “target”, “desired”, which are parameters sets from Ref. [1].

  • noise_channel_prescription (str, optional) – Name of prescription. Current option are [‘circuit’]. Defaults to ‘circuit’.

Returns:

The noise model.

Return type:

PhysicalDepolarizing

input_noise_parameters: NoiseModelParameters_PhysicalDepolarizing
noise_model_name = 'physical_depolarizing'
static strength_gate_operation_noise_channel(F: float, n: int) float[source]

Calculate the strength p of a depolarizing noise channel whose average gate fidelity is F.

The channel parameterization assumes that (1-p) is the probability of leaving the input state unaltered.

Parameters:
  • F (float) – Average gate fidelity.

  • n (float) – number of gate qubits.

static strength_idle_qubit_noise_channel(T1_longitudinal_relaxation_time: float, t: float) float[source]

Calculate the strength p of a single qubit depolarizing noise channel on an idle qubit.

This is equivalent to the decay/dephasing channel with the thermal equilibrium state alpha_0 = 1/2 (see Eq. (7.144) of Ref. [1]). The physical meaning of alpha_0 = 1/2 is that it corresponds to the limit where the equilibrium temperature is infinite. The depolarizing channel parameterization assumes that (1 - p) is the probability of leaving the input state unaltered. It is assumed that the T2 (dephasing time) is equal to the T1 (relaxation time).

[1] M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed (Cambridge University Press, 2010).

Parameters:
  • T1_relaxation_time (float) – The T1 of a qubit.

  • t (float) – The idling duration of the qubit.

static strength_idle_qubit_stochastic_noise_channel(T1_longitudinal_relaxation_time: float, T2_transverse_relaxation_time: float, t: float) tuple[float, float, float][source]

Calculate the strength p of a single qubit stochastic Pauli noise channel on an idle qubit.

This is equivalent to the decay/dephasing channel with the thermal equilibrium state alpha_0 = 1/2 (see Eq. (7.144) of Ref. [1]). The physical meaning of alpha_0 = 1/2 is that it corresponds to the limit where the equilibrium temperature is infinite. The stochastic Pauli channel parameterization assumes that (1 - px - py - pz) is the probability of leaving the input state unaltered.

[1] M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed (Cambridge University Press, 2010).

Parameters:
  • T1_longitudinal_relaxation_time (float) – The T1 of a qubit.

  • T2_transverse_relaxation_time (float) – The T2 of a qubit.

  • t (float) – The idling duration of the qubit.

static strength_spam_operation_noise_channel(F: float) float[source]

Calculate the strength p of a Pauli X noise channel whose average fidelity is F.

F is assumed to be:

F = 1 - (P(1|0) + P(0|1))/2

i.e. one minus the average probability that the desired/prepared state has indeed been prepared/measured. The channel parameterization assumes that (1-p_x) is the probability of leaving the input state unaltered, and p_x is the probability that X error has been applied.

Parameters:

F (float) – Fidelity of the SPAM operation.

class topqad_sdk.noiseprofiler.libnoise.Quantity(*, value: float, unit: str)[source]

Bases: BaseModel

A basic quantity with a value and unit.

classmethod from_raw_value(raw_value: float, unit: str) Quantity[source]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

unit: str
value: float
class topqad_sdk.noiseprofiler.libnoise.UniformDepolarizing(*, p: float, stabilization_time: Quantity = Quantity(value=1.0, unit='μs'), noise_channel_prescription: str = 'circuit')[source]

Bases: NoiseModel

A simple uniform depolarizing noise model, in which all noise channels have the same strength $p$. The noise channels added before or after every circuit operations are as follows.

  • Preparation and reset are followed by bit or phase flip errors, depending on the basis.

  • Measurements are noisy with probability $p$ of error, and are followed by a one-qubit depolarizing noise channel.

  • One-qubit gates are followed by a one-qubit depolarizing noise channel.

  • Two-qubit gates are followed by a two-qubit depolarizing noise channel.

  • Idle qubits experience a one-qubit depolarizing noise channel at each tick.

This model was inspired by the model described in Appendix A of Ref. [1].

### References

[1] C. Gidney, N. Shutty, and C. Jones, Magic State Cultivation: Growing T States as Cheap as CNOT Gates, (2024)

arXiv:2409.17595.

calculate_stabilization_time(unit='μs')[source]

Calculate the stabilization time.

Parameters:

unit (str) – An acceptable unit of time.

Returns:

stabilization time.

Return type:

Quantity

classmethod from_dict(noise_parameter_dictionary: dict[str, float], noise_channel_prescription: str = 'circuit')[source]

Create noise model from a dictionary of parameters.

Parameters:
  • noise_parameter_dictionary (dict[str, float]) – The dictionary of parameters. Dictionary is of the form {“p”: 0.01}.

  • noise_channel_prescription (str, optional) – Name of prescription. Current option are [‘circuit’]. Defaults to ‘circuit’.

input_noise_parameters: NoiseModelParameters_UniformDepolarizing
noise_model_name = 'uniform_depolarizing'