Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into upgrade_python3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
rodolfocarobene committed Jun 7, 2024
2 parents 5487399 + 69de0e2 commit 98b4668
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 109 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 of 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 of 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 of 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
12 changes: 3 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 of 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,6 @@ 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

#setting the scale_factors
self.scale_factors = scale_factors
Expand Down
2 changes: 1 addition & 1 deletion src/openqaoa-core/openqaoa/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def plot_graph(G: nx.Graph, ax=None, colormap="seismic") -> None:
# extract minimum and maximum weights for side bar limits
weights = list(edges_and_weights.values())
# Define color map
cmap = plt.cm.get_cmap(colormap)
cmap = plt.get_cmap(colormap)

if len(set(weights)) > 1:
edge_vmin = min(weights)
Expand Down
Loading

0 comments on commit 98b4668

Please sign in to comment.