qermit.zero_noise_extrapolation¶
- zne.gen_ZNE_MitEx(rebase_pass: pytket._tket.passes.BasePass, noise_scaling_list: List[float], **kwargs) → qermit.taskgraph.mitex.MitEx¶
Generates MitEx object which mitigates for noise using Zero Noise Extrapolation. This is the process by which noise is amplified incrementally, and the zero noise case arrived at by extrapolating backwards. For further explanantion see https://arxiv.org/abs/2005.10921.
- Parameters
backend (Backend) – Backend on which the circuits are to be run.
rebase_pass (BasePass) – BasePass rebasing to the gateset of the backend.
noise_scaling_list (List[float]) – A list of the amounts by which the noise should be scaled.
- Returns
MitEx object performing noise mitigation by ZNE.
- Return type
- class qermit.zero_noise_extrapolation.zne.Folding(value)¶
Folding techniques used to increase the noise levels.
- Returns
Circuit with gate count increased to scale noise. The unitary implemented by the circuit has not changed.
- Return type
Circuit
- circuit(noise_scaling: int, **kwargs) → pytket._tket.circuit.Circuit¶
Noise scaling by circuit folding. In this case the folded circuit is of the form \(CC^{-1}CC^{-1}...C\) where \(C\) is the original circuit. As such noise may be scaled by odd integers. The Unitary implemented is unchanged by this process.
- Parameters
circ (Circuit) – Original circuit to be folded.
noise_scaling (int) – Factor by which to scale the noise. This must be an odd integer.
- Raises
ValueError – Raised if the amount by which the noise should be scaled is not an odd integer.
- Returns
Folded circuit implementing identical unitary to the initial circuit.
- Return type
Circuit
- gate(noise_scaling: float, **kwargs) → pytket._tket.circuit.Circuit¶
Noise scaling by gate folding. In this case gates \(G\) are replaced at random with \(GG^{-1}G\) until the number of gates is sufficiently scaled.
- Parameters
circ (Circuit) – Original circuit to be folded.
noise_scaling (float) – Factor by which to increase the noise.
- Key _allow_approx_fold
Allows for the noise to be increased by an amount close to that requested, as opposed to by exactly the amount requested. This is necessary as there are cases where the exact noise scaling cannot be achieved. This occurs due to the discrete amounts by which the noise can be increased (i.e. the discrete amount by which one gate increases the noise).
- Raises
ValueError – Raised if the requested noise scaling cannot be exactly achieved. This can be avoided by appropriately setting _allow_approx_fold.
- Returns
Folded circuit implementing identical unitary to the initial circuit.
- Return type
Circuit
- odd_gate(noise_scaling: int, **kwargs) → pytket._tket.circuit.Circuit¶
Noise scaling by gate folding. In this case odd gates \(G\) are replaced \(GG^{-1}G\) until the number of gates is sufficiently scaled.
- Parameters
circ (Circuit) – Original circuit to be folded.
noise_scaling (float) – Factor by which to increase the noise.
- Returns
Folded circuit implementing identical unitary to the initial circuit.
- Return type
Circuit
- class qermit.zero_noise_extrapolation.zne.Fit(value)¶
Functions to fit to expectation values as they change with noise.
- Returns
Extrapolation of expectation values to the zero noise limit.
- Return type
float
- cube_root(x: List[float], y: List[float], _show_fit: bool, *args) → float¶
Fit data to a cube root function. This is to say a function of the form \(a + b(x+c)^{1/3}\).
- Parameters
x (List[float]) – Noise scaling values.
y (List[float]) – Expectation values.
_show_fit (bool) – Plot data and resulting fitted function.
- Returns
Extrapolation of data to zero noise limit using the best fitting cube root function.
- Return type
float
- exponential(x: List[float], y: List[float], _show_fit: bool, *args) → float¶
Fit data to an exponential function. This is to say a function of the form \(a+e^{(b+x)}\). Note that this is a special case of the poly-exponential function.
- Parameters
x (List[float]) – Noise scaling values.
y (List[float]) – Expectation values.
_show_fit (bool) – Plot data and resulting fitting function.
- Returns
Extrapolation to zero noise limit using the best fitting exponential function.
- Return type
float
- linear(x: List[float], y: List[float], _show_fit: bool, *args) → float¶
Fit data to a linear function. This is to say a function of the form \(ax+b\). Note that this is a special case of the polynomial fitting function.
- Parameters
x (List[float]) – Noise scaling values.
y (List[float]) – Expectation values.
_show_fit (bool) – Plot data and resulting fitted function.
- Returns
Extrapolation to zero noise limit using the best fitting linear function.
- Return type
float
- poly_exponential(x: List[float], y: List[float], _show_fit: bool, deg: int) → float¶
Fit data to a poly-exponential, which is to say a function of the form \(a+e^{z}\), where \(z\) is a polynomial.
- Parameters
x (List[float]) – Noise scaling values.
y (List[float]) – Expectation values.
_show_fit (bool) – Plot data and resulting fitted function.
deg (int) – The degree of the polynomial in the exponential.
- Raises
ValueError – Raised if the degree of the polynomial inputted is negative, or too high to fit to the data.
- Returns
Extrapolation of data to the zero noise limit using the best fitting poly-exponential function of the specified degree.
- Return type
float
- polynomial(x: List[float], y: List[float], _show_fit: bool, deg: int) → float¶
Fit data to a polynomial function.
- Parameters
x (List[float]) – Noise scaling values.
y (List[float]) – Expectation values.
_show_fit (bool) – Plot data and resulting fitting function.
deg (int) – The degree of the function to fit to.
- Raises
ValueError – Raised if the degree of the polynomial is negative, or too high to fit the data to.
- Returns
Extrapolation to zero noise limit using the best fitting polynomial function of the specified degree.
- Return type
float
- richardson(x: List[float], y: List[float], _show_fit: bool, *args) → float¶
Use richardson extrapolation. This amounts to fitting to a polynomial of degree one less than the number of data points.
- Parameters
x (List[float]) – Noise scaling values.
y (List[float]) – Expectation values.
_show_fit (bool) – Plot data and resulting fitted function.
- Returns
Extrapolation to zero noise limit using Richardson extrapolation.
- Return type
float
- zne.digital_folding_task_gen(rebase_pass: pytket._tket.passes.BasePass, noise_scaling: float, _folding_type: qermit.zero_noise_extrapolation.zne.Folding, _allow_approx_fold: bool) → qermit.taskgraph.mittask.MitTask¶
Generates task transforming a circuit in order to amplify the noise. The noise is increased by a factor noise_scaling using the inputted folding method.
- Parameters
backend (Backend) – This will be used to compile the circuit after folding to ensure that the gate set matches those available on the backend.
rebase_pass (BasePass) – BasePass to rebase circuits to the native gates of backend
noise_scaling (float) – The factor by which the noise is increased.
_folding_type (Folding) – The means by which the noise should be increased.
_allow_approx_fold (bool) – Allows for the noise to be increased by an amount close to that requested, as opposed to by exactly the amount requested. This is necessary as there are cases where the exact noise scaling cannot be achieved. This occurs due to the discrete amounts by which the noise can be increased (i.e. the discrete amount by which one gate increases the noise).
- zne.extrapolation_task_gen(_fit_type: qermit.zero_noise_extrapolation.zne.Fit, _show_fit: bool, deg: int) → qermit.taskgraph.mittask.MitTask¶
Generates task extrapolating to the zero noise limit using results from many folded circuits.
- Parameters
noise_scaling_list (List[float]) – A list of the values by which the noise has been folded.
_fit_type (Fit) – The function used to fit to the resulting data.
_show_fit (bool) – Plot data and resulting fitted function.
deg (int) – The degree of polynomials used.