mitigate_with_zne¶
- mitigate_with_zne(f, *, scale_factors: jax.Array, deg: Optional[int] = None)[source]¶
A
qjit()
compatible error mitigation of an input circuit using zero-noise extrapolation.Error mitigation is a precursor to error correction and is compatible with near-term quantum devices. It aims to lower the impact of noise when evaluating a circuit on a quantum device by evaluating multiple variations of the circuit and post-processing the results into a noise-reduced estimate. This transform implements the zero-noise extrapolation (ZNE) method originally introduced by Temme et al. and Li et al..
- Parameters
f (qml.QNode) – the circuit to be mitigated.
scale_factors (array[int]) – the range of noise scale factors used.
deg (int) – the degree of the polymonial used for fitting.
- Returns
A callable object that computes the mitigated of the wrapped
qml.QNode
for the given arguments.- Return type
Callable
Example:
For example, given a noisy device (such as noisy hardware available through Amazon Braket):
# replace "noisy.device" with your noisy device dev = qml.device("noisy.device", wires=2) @qml.qnode(device=dev) def circuit(x, n): @for_loop(0, n, 1) def loop_rx(i): qml.RX(x, wires=0) loop_rx() qml.Hadamard(wires=0) qml.RZ(x, wires=0) loop_rx() qml.RZ(x, wires=0) qml.CNOT(wires=[1, 0]) qml.Hadamard(wires=1) return qml.expval(qml.PauliY(wires=0)) @qjit def mitigated_circuit(args, n): s = jax.numpy.array([1, 2, 3]) return mitigate_with_zne(circuit, scale_factors=s)(args, n)