Skip to content

Commit

Permalink
LRE build error (unitaryfund#2541)
Browse files Browse the repository at this point in the history
* minor change

* try full path

* line - rtd failure

* undo full path

* try changing import order

* import test failures

* try adding init files

* import paths in user guide

* submodules in main init

* new line in init
  • Loading branch information
purva-thakre authored Oct 22, 2024
1 parent 54f7171 commit ecfa7dc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
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,
)

0 comments on commit ecfa7dc

Please sign in to comment.