Skip to content

Commit

Permalink
Remove outdated folding functions in mitiq
Browse files Browse the repository at this point in the history
  • Loading branch information
KilianPoirier committed May 28, 2024
1 parent 7f84b11 commit 488e7ec
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/15_Zero_Noise_Extrapolation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
"Available options to set up the ZNE with `set_error_mitigation_properties`:\n",
"\n",
"- **factory**: The name of the zero-noise extrapolation method. Supported values: \"Richardson\", \"Linear\", \"Poly\", \"Exp\", \"PolyExp\", \"AdaExp\", \"FakeNodes\".\n",
"- **scaling**: The name of the function for scaling the noise of a quantum circuit. Supported values: \"fold_gates_at_random\", \"fold_gates_from_right\", \"fold_gates_from_left\".\n",
"- **scaling**: The name of the function for scaling the noise of a quantum circuit. Supported values: \"fold_gates_at_random\" (\"fold_gates_from_right\", \"fold_gates_from_left\" not supported as version 0.8).\n",
"- **scale_factors**: List[int] Sequence of noise scale factors at which expectation values should be measured. For factory = \"AdaExp\", just the first element of the list will be considered.\n",
"- **order**: Extrapolation order (degree of the polynomial fit). It cannot exceed len(scale_factors) - 1. Only used for factory = \"Poly\" or \"PolyExp\".\n",
"- **steps**: The number of optimization steps. At least 3 are necessary. Only used for factory = \"AdaExp\"."
Expand Down
2 changes: 1 addition & 1 deletion src/openqaoa-core/openqaoa/algorithms/baseworkflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def set_error_mitigation_properties(self, **kwargs):
factory: str
Used in "mitiq_zne". The name of the zero-noise extrapolation method. Supported values: "Richardson", "Linear", "Poly", "Exp", "PolyExp", "AdaExp", "FakeNodes".
scaling: str
Used in "mitiq_zne". The name of the function for scaling the noise of a quantum circuit. Supported values: "fold_gates_at_random", "fold_gates_from_right", "fold_gates_from_left".
Used in "mitiq_zne". The name of the function for scaling the noise of a quantum circuit. Supported values: "fold_gates_at_random" ("fold_gates_from_right", "fold_gates_from_left" not supported as version 0.8)
scale_factors: List[int]
Used in "mitiq_zne". Sequence of noise scale factors at which expectation values should be measured.
For factory = "AdaExp", just the first element of the list will be considered.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class MitiqZNEProperties(ErrorMitigationProperties):
factory: str
The name of the zero-noise extrapolation method. Supported values: "Richardson", "Linear", "Poly", "Exp", "PolyExp", "AdaExp", "FakeNodes".
scaling: str
The name of the function for scaling the noise of a quantum circuit. Supported values: "fold_gates_at_random", "fold_gates_from_right", "fold_gates_from_left".
The name of the function for scaling the noise of a quantum circuit. Supported values: "fold_gates_at_random" ("fold_gates_from_right", "fold_gates_from_left" not supported as version 0.8).
scale_factors: List[int]
Sequence of noise scale factors at which expectation values should be measured.
For factory = "AdaExp", just the first element of the list will be considered.
Expand Down
16 changes: 7 additions & 9 deletions src/openqaoa-core/openqaoa/backends/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json

from mitiq.zne.inference import RichardsonFactory, LinearFactory, PolyExpFactory, PolyFactory, AdaExpFactory, FakeNodesFactory, ExpFactory
from mitiq.zne.scaling import fold_gates_at_random, fold_gates_from_left, fold_gates_from_right
from mitiq.zne.scaling import fold_gates_at_random
from mitiq.zne import execute_with_zne

import copy
Expand Down Expand Up @@ -75,8 +75,6 @@ def exact_solution(self, *args, **kwargs):
]
available_scaling = [
"fold_gates_at_random",
"fold_gates_from_right",
"fold_gates_from_left"
]
class ZNEWrapper(BaseWrapper):
"""
Expand All @@ -92,7 +90,7 @@ class ZNEWrapper(BaseWrapper):
factory: str
The name of the zero-noise extrapolation method. Supported values: "Richardson", "Linear", "Poly", "Exp", "PolyExp", "AdaExp", "FakeNodes".
scaling: str
The name of the function for scaling the noise of a quantum circuit. Supported values: "fold_gates_at_random", "fold_gates_from_right", "fold_gates_from_left".
The name of the function for scaling the noise of a quantum circuit. Supported values: "fold_gates_at_random" ("fold_gates_from_right", "fold_gates_from_left" not supported as version 0.8).
scale_factors: List[int]
Sequence of noise scale factors at which expectation values should be measured.
For factory = "AdaExp", just the first element of the list will be considered.
Expand All @@ -116,7 +114,7 @@ def __init__(self, backend, factory, scaling, scale_factors, order, steps):
if(factory not in available_factories):
raise ValueError("Supported factories are: Poly, Richardson, Exp, FakeNodes, Linear, PolyExp, AdaExp")
if(scaling not in available_scaling):
raise ValueError("Supported scaling methods are: fold_gates_at_random, fold_gates_from_right, fold_gates_from_left")
raise ValueError("Supported scaling methods are: fold_gates_at_random")
if(not isinstance(scale_factors, list) or not all(isinstance(x, int) and x >= 1 for x in scale_factors)):
raise ValueError("Scale factor must be a list of ints greater than or equal to 1")
if(type(order) != int or order < 1):
Expand Down Expand Up @@ -145,10 +143,10 @@ def __init__(self, backend, factory, scaling, scale_factors, order, steps):
self.scale_noise = None
if scaling == "fold_gates_at_random":
self.scale_noise = fold_gates_at_random
elif scaling == "fold_gates_from_left":
self.scale_noise = fold_gates_from_left
elif scaling == "fold_gates_from_right":
self.scale_noise = fold_gates_from_right
# elif scaling == "fold_gates_from_left":
# self.scale_noise = fold_gates_from_left
# elif scaling == "fold_gates_from_right":
# self.scale_noise = fold_gates_from_right

#setting the scale_factors
self.scale_factors = scale_factors
Expand Down

0 comments on commit 488e7ec

Please sign in to comment.