qml.NoiseModel¶
- class NoiseModel(model_map, meas_map=None, **kwargs)[source]¶
Bases:
object
Builds a noise model based on the mappings of conditionals to callables that define noise operations using some optional metadata.
- Parameters
model_map (dict[BooleanFn -> Callable]) – Data for applying the gate errors as a
{conditional: noise_fn}
dictionary. The signature ofnoise_fn
should benoise_fn(op: Operation, **kwargs) -> None
, whereop
is the operation that the conditional evaluates andkwargs
are the specified metadata arguments.meas_map (dict[BooleanFn -> Callable]) – Data for adding the readout errors similar to
model_map
. The signature ofnoise_fn
must benoise_fn(mp: MeasurementProcess, **kwargs) -> None
, wheremp
is the measurement process that the conditional evaluates andkwargs
are the specified metadata arguments.**kwargs – Keyword arguments for specifying metadata related to the noise model.
Note
For each key-value pair of
model_map
andmeas_map
:The
conditional
should be either a function decorated withBooleanFn
, a callable object built via constructor functions in theqml.noise
module, or their bitwise combination.The definition of
noise_fn(Union[op, mp], **kwargs)
should have the operations in the same order in which they are to be queued for an operationop
or measurement processmp
, whenever the correspondingconditional
evaluates toTrue
.Each
conditional
inmeas_map
is evaluated on each measurement process in the order they are specified. The corresponding noise has to be added before the measurement, i.e., custom queing innoise_fn
should not be done.
Example
# Set up the gate noise 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]) 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 the readout noise m0 = qml.noise.meas_eq(qml.expval) & qml.noise.wires_in([0, 1]) n2 = qml.noise.partial_wires(qml.PhaseFlip, 0.2) # Set up noise model noise_model = qml.NoiseModel({c0: n0}, meas_map={m0:n2}, t1=0.04) noise_model += {c1: n1}
>>> noise_model NoiseModel({ OpEq(PauliX) | OpEq(PauliY): n0 OpEq(Hadamard) & WiresIn([0, 1]): AmplitudeDamping(0.4, wires), }, meas_map = { MeasEq(expval) & WiresIn([0, 1]): PhaseFlip(p=0.2) }, t1=0.04)
Attributes
Gives the measurement model for the noise model.
Gives the metadata for the noise model.
Gives the conditional model for the noise model.
- meas_map¶
Gives the measurement model for the noise model.
- metadata¶
Gives the metadata for the noise model.
- model_map¶
Gives the conditional model for the noise model.
Methods
check_model
(model)Method to validate a
{conditional -> noise_fn}
map for constructing a noise model.