Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LRE build error #2541

Merged
merged 10 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions docs/source/guide/lre-1-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ mitigated = execute_with_lre(
fold_multiplier=fold_multiplier,
)


print(f"Error with mitigation (LRE): {abs(ideal - mitigated):.{3}}")
```

Expand All @@ -92,7 +93,7 @@ In this section we demonstrate the use of {func}`.multivariate_layer_scaling` an
We start by creating a number of noise-scaled circuits which we will pass to the executor.

```{code-cell} ipython3
from mitiq.lre import multivariate_layer_scaling
from mitiq.lre.multivariate_scaling import multivariate_layer_scaling


noise_scaled_circuits = multivariate_layer_scaling(circuit, degree, fold_multiplier)
Expand Down Expand Up @@ -125,7 +126,7 @@ The penultimate step here is to fetch the coefficients we'll use to combine the
The astute reader will note that we haven't defined or used a `degree` or `fold_multiplier` parameter, and this is where they are both needed.

```{code-cell} ipython3
from mitiq.lre import multivariate_richardson_coefficients
from mitiq.lre.inference import multivariate_richardson_coefficients


coefficients = multivariate_richardson_coefficients(
Expand All @@ -144,9 +145,7 @@ mitigated = sum(
exp_val * coeff
for exp_val, coeff in zip(noise_scaled_exp_values, coefficients)
)
print(
f"Error with mitigation (LRE): {abs(ideal - mitigated):.{3}}"
)
print(f"Error with mitigation (LRE): {abs(ideal - mitigated):.{3}}")
```

As you can see we again see a nice improvement in the accuracy using a two stage application of LRE.
9 changes: 3 additions & 6 deletions mitiq/lre/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@

"""Methods for scaling noise in circuits by layers and using multivariate extrapolation."""

from mitiq.lre.multivariate_scaling.layerwise_folding import multivariate_layer_scaling
from mitiq.lre.lre import execute_with_lre, mitigate_executor, lre_decorator

from mitiq.lre.inference.multivariate_richardson import (
multivariate_richardson_coefficients,
sample_matrix,
)
from mitiq.lre import multivariate_scaling

from mitiq.lre.lre import execute_with_lre, mitigate_executor, lre_decorator
from mitiq.lre import inference
3 changes: 3 additions & 0 deletions mitiq/lre/inference/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from mitiq.lre.inference.multivariate_richardson import (
multivariate_richardson_coefficients,
)
6 changes: 4 additions & 2 deletions mitiq/lre/lre.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
from cirq import Circuit

from mitiq import QPROGRAM
from mitiq.lre import (
multivariate_layer_scaling,
from mitiq.lre.inference import (
multivariate_richardson_coefficients,
)
from mitiq.lre.multivariate_scaling import (
multivariate_layer_scaling,
)
from mitiq.zne.scaling import fold_gates_at_random


Expand Down
6 changes: 6 additions & 0 deletions mitiq/lre/multivariate_scaling/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

"""Methods for scaling noise in circuits by layers as required for LRE."""

from mitiq.lre.multivariate_scaling.layerwise_folding import (
multivariate_layer_scaling,
)
Loading