From 488e7ece8835f2b02ba7caad811e44076ee76554 Mon Sep 17 00:00:00 2001 From: KilianPoirier Date: Tue, 28 May 2024 03:24:40 +0000 Subject: [PATCH] Remove outdated folding functions in mitiq --- examples/15_Zero_Noise_Extrapolation.ipynb | 2 +- .../openqaoa/algorithms/baseworkflow.py | 2 +- .../openqaoa/algorithms/workflow_properties.py | 2 +- src/openqaoa-core/openqaoa/backends/wrapper.py | 16 +++++++--------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/examples/15_Zero_Noise_Extrapolation.ipynb b/examples/15_Zero_Noise_Extrapolation.ipynb index 4225b393..5a6c5430 100644 --- a/examples/15_Zero_Noise_Extrapolation.ipynb +++ b/examples/15_Zero_Noise_Extrapolation.ipynb @@ -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\"." diff --git a/src/openqaoa-core/openqaoa/algorithms/baseworkflow.py b/src/openqaoa-core/openqaoa/algorithms/baseworkflow.py index ab2c43ab..f31b33d2 100644 --- a/src/openqaoa-core/openqaoa/algorithms/baseworkflow.py +++ b/src/openqaoa-core/openqaoa/algorithms/baseworkflow.py @@ -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. diff --git a/src/openqaoa-core/openqaoa/algorithms/workflow_properties.py b/src/openqaoa-core/openqaoa/algorithms/workflow_properties.py index a49a1a17..4720e9c5 100644 --- a/src/openqaoa-core/openqaoa/algorithms/workflow_properties.py +++ b/src/openqaoa-core/openqaoa/algorithms/workflow_properties.py @@ -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. diff --git a/src/openqaoa-core/openqaoa/backends/wrapper.py b/src/openqaoa-core/openqaoa/backends/wrapper.py index 14d90a4e..4257ff0e 100644 --- a/src/openqaoa-core/openqaoa/backends/wrapper.py +++ b/src/openqaoa-core/openqaoa/backends/wrapper.py @@ -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 @@ -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): """ @@ -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. @@ -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): @@ -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