uniqc.simulator.error_model module#

Quantum error models for noisy simulation.

This module defines various quantum noise models that can be applied to circuit simulations, including bit-flip, phase-flip, depolarizing, amplitude damping, and Kraus operator errors.

Key exports:
  • ErrorModel: Base class for all error models.

  • BitFlip: Bit-flip (X) error model.

  • PhaseFlip: Phase-flip (Z) error model.

  • Depolarizing: Single-qubit depolarizing channel.

  • TwoQubitDepolarizing: Two-qubit depolarizing channel.

  • AmplitudeDamping: Amplitude damping (T1) error model.

  • PauliError1Q: Single-qubit Pauli error model.

  • PauliError2Q: Two-qubit Pauli error model.

  • Kraus1Q: Single-qubit Kraus operator error model.

  • ErrorLoader: Base error loader interface.

  • ErrorLoader_GenericError: Generic error loader.

  • ErrorLoader_GateTypeError: Gate-type specific error loader.

  • ErrorLoader_GateSpecificError: Gate-specific error loader.

class uniqc.simulator.error_model.AmplitudeDamping(gamma)[source]#

Bases: ErrorModel

Amplitude damping error model.

Parameters:

gamma (float) – Damping rate (0 to 1).

gamma: float#
generate_error_opcode(qubits)[source]#

Generate AmplitudeDamping error opcodes for the given qubits.

Parameters:

qubits (int | list[int]) – Qubit or list of qubits to apply error to.

Returns:

List of error opcodes.

Return type:

list[tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None]]

class uniqc.simulator.error_model.BitFlip(p)[source]#

Bases: ErrorModel

Bit-flip error model.

Parameters:

p (float) – Bit-flip probability.

generate_error_opcode(qubits)[source]#

Generate BitFlip error opcodes for the given qubits.

Parameters:

qubits (int | list[int]) – Qubit or list of qubits to apply error to.

Returns:

List of error opcodes.

Return type:

list[tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None]]

p: float#
class uniqc.simulator.error_model.Depolarizing(p)[source]#

Bases: ErrorModel

Depolarizing error model for single qubits.

Parameters:

p (float) – Depolarizing probability.

generate_error_opcode(qubits)[source]#

Generate Depolarizing error opcodes for the given qubits.

Parameters:

qubits (int | list[int]) – Qubit or list of qubits to apply error to.

Returns:

List of error opcodes.

Return type:

list[tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None]]

p: float#
class uniqc.simulator.error_model.ErrorLoader[source]#

Bases: object

Load opcodes into the simulator with noise models.

Base class that inserts error opcodes into the program.

insert_error(opcode)[source]#

Insert error opcodes for the given opcode. Override in subclasses.

Parameters:

opcode (tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None])

Return type:

None

insert_opcode(opcode)[source]#

Append the original opcode and insert associated errors.

Parameters:

opcode (tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None])

Return type:

None

opcodes: list[tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None]]#
process_opcodes(opcodes)[source]#

Process a list of opcodes, inserting errors for each.

Parameters:

opcodes (list[tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None]])

Return type:

None

class uniqc.simulator.error_model.ErrorLoader_GateSpecificError(generic_error, gatetype_error, gate_specific_error)[source]#

Bases: ErrorLoader_GateTypeError

Load opcodes with gate-specific noise (including per qubit-pair).

Supports generic errors, per-gate-type errors, and per-gate-instance errors (keyed by gate name and specific qubit(s)).

Parameters:
gate_specific_error: dict[tuple[str, tuple[int, int]], list[ErrorModel]]#
insert_error(opcode)[source]#

Insert generic, gate-type, and gate-specific errors for the given opcode.

Parameters:

opcode (tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None])

Return type:

None

class uniqc.simulator.error_model.ErrorLoader_GateTypeError(generic_error, gatetype_error)[source]#

Bases: ErrorLoader_GenericError

Load opcodes with gate-dependent noise.

Supports both generic errors (applied to all gates) and per-gate-type errors (applied only to specific gate types).

Parameters:
gatetype_error: dict[str, list[ErrorModel]]#
insert_error(opcode)[source]#

Insert generic and gate-type-specific errors for the given opcode.

Parameters:

opcode (tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None])

Return type:

None

class uniqc.simulator.error_model.ErrorLoader_GenericError(generic_error)[source]#

Bases: ErrorLoader

Load opcodes with generic (gate-independent) noise.

Applies the same set of error models to every gate.

Parameters:

generic_error (list[ErrorModel])

generic_error: list[ErrorModel]#
insert_error(opcode)[source]#

Insert generic errors for the given opcode.

Parameters:

opcode (tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None])

Return type:

None

class uniqc.simulator.error_model.ErrorModel[source]#

Bases: object

Base class for quantum error models.

generate_error_opcode(qubits)[source]#

Generate error opcodes for the given qubits.

Parameters:

qubits (int | list[int]) – Qubit or list of qubits to apply error to.

Returns:

List of error opcodes.

Return type:

list[tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None]]

class uniqc.simulator.error_model.Kraus1Q(kraus_ops)[source]#

Bases: ErrorModel

Single-qubit Kraus operator error model.

Parameters:

kraus_ops (list[list[complex]]) – List of Kraus operators (2x2 matrices).

generate_error_opcode(qubits)[source]#

Generate Kraus1Q error opcodes for the given qubits.

Parameters:

qubits (int | list[int]) – Qubit or list of qubits to apply error to.

Returns:

List of error opcodes.

Return type:

list[tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None]]

kraus_ops: list[list[complex]]#
class uniqc.simulator.error_model.PauliError1Q(p_x, p_y, p_z)[source]#

Bases: ErrorModel

Single-qubit Pauli error model with independent X, Y, Z probabilities.

Parameters:
  • p_x (float) – Probability of X error.

  • p_y (float) – Probability of Y error.

  • p_z (float) – Probability of Z error.

generate_error_opcode(qubits)[source]#

Generate PauliError1Q opcodes for the given qubits.

Parameters:

qubits (int | list[int]) – Qubit or list of qubits to apply error to.

Returns:

List of error opcodes.

Return type:

list[tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None]]

p_x: float#
p_y: float#
p_z: float#
class uniqc.simulator.error_model.PauliError2Q(ps)[source]#

Bases: ErrorModel

Two-qubit Pauli error model with 15 independent probabilities.

Parameters:

ps (list[float]) – List of 15 Pauli error probabilities.

generate_error_opcode(qubits)[source]#

Generate PauliError2Q opcodes for the given qubit pair.

Parameters:

qubits (int | list[int]) – List of exactly two qubits.

Returns:

List of error opcodes.

Raises:

ValueError – If not exactly two qubits are provided.

Return type:

list[tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None]]

ps: list[float]#
class uniqc.simulator.error_model.PhaseFlip(p)[source]#

Bases: ErrorModel

Phase-flip (Z) error model.

Parameters:

p (float) – Phase-flip probability.

generate_error_opcode(qubits)[source]#

Generate PhaseFlip error opcodes for the given qubits.

Parameters:

qubits (int | list[int]) – Qubit or list of qubits to apply error to.

Returns:

List of error opcodes.

Return type:

list[tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None]]

p: float#
class uniqc.simulator.error_model.TwoQubitDepolarizing(p)[source]#

Bases: ErrorModel

Two-qubit depolarizing error model.

Parameters:

p (float) – Depolarizing probability.

generate_error_opcode(qubits)[source]#

Generate TwoQubitDepolarizing error opcodes for the given qubit pair.

Parameters:

qubits (int | list[int]) – List of exactly two qubits.

Returns:

List of error opcodes.

Raises:

ValueError – If not exactly two qubits are provided.

Return type:

list[tuple[str, int | list[int], Any, float | tuple[float, float, float] | list[complex] | None, None, None]]

p: float#