qml.NoiseModel

class NoiseModel(model_map, **kwargs)[source]

Bases: object

Builds a noise model based on a mapping of conditionals to callables that defines noise operations using some optional metadata.

Parameters
  • model_map (dict[BooleanFn -> Callable]) – Data for the noise model as a {conditional: noise_fn} dictionary. The signature of noise_fn must be noise_fn(op: Operation, **kwargs) -> None, where op is the operation that the conditional evaluates and kwargs are the specified metadata arguments.

  • **kwargs – Keyword arguments for specifying metadata related to noise model.

Note

For each key-value pair of model_map:

  • The conditional should be either a function decorated with BooleanFn, a callable object built via constructor functions in the qml.noise module, or their bitwise combination.

  • The definition of noise_fn(op, **kwargs) should have the operations in the same the order in which they are to be queued for an operation op, whenever the corresponding conditional evaluates to True.

Example

# Set up the conditionals
c0 = qml.noise.op_eq(qml.PauliX) | qml.noise.op_eq(qml.PauliY)
c1 = qml.noise.op_eq(qml.Hadamard) & qml.noise.wires_in([0, 1])

# Set up the noise functions
def n0(op, **kwargs):
    qml.ThermalRelaxationError(0.4, kwargs["t1"], 0.2, 0.6, op.wires)

n1 = qml.noise.partial_wires(qml.AmplitudeDamping, 0.4)

# Set up noise model
noise_model = qml.NoiseModel({c0: n0}, t1=0.04)
noise_model += {c1: n1}
>>> noise_model
NoiseModel({
    OpEq(PauliX) | OpEq(PauliY): n0
    OpEq(Hadamard) & WiresIn([0, 1]): AmplitudeDamping(0.4, wires),
}, t1=0.04)

metadata

Gives the metadata for the noise model.

model_map

Gives the conditional model for the noise model.

metadata

Gives the metadata for the noise model.

model_map

Gives the conditional model for the noise model.

check_model(model)

Method to validate the model map for constructing a NoiseModel.

static check_model(model)[source]

Method to validate the model map for constructing a NoiseModel.