From 071fffaaa75f9d18842012bbb467b4f88c818af7 Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Tue, 12 Mar 2024 13:56:59 -0400 Subject: [PATCH 01/11] Remove approximation=true from Aer page --- docs/verify/simulate-with-qiskit-aer.ipynb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/docs/verify/simulate-with-qiskit-aer.ipynb b/docs/verify/simulate-with-qiskit-aer.ipynb index e248ccd195e..a132d297464 100644 --- a/docs/verify/simulate-with-qiskit-aer.ipynb +++ b/docs/verify/simulate-with-qiskit-aer.ipynb @@ -43,11 +43,7 @@ "id": "db010004-7a23-4c64-9cb3-8768f805e22a", "metadata": {}, "source": [ - "This circuit contains parameters to represent the rotation angles for $R_y$ and $R_z$ gates. When simulating this circuit, we need to specify explicit values for these parameters. In the next cell, we specify some values for these parameters and use the [Estimator](https://qiskit.org/ecosystem/aer/stubs/qiskit_aer.primitives.Estimator.html) primitive from Qiskit Aer to compute the exact expectation value of the observable $ZZ \\cdots Z$.\n", - "\n", - "\n", - "Setting `approximation=True` when initializing the Estimator tells Qiskit Aer to approximate the effect of sampling error rather than actually perform sampling. This makes the simulation much more efficient, and also allows us to calculate the exact expectation value, free of sampling error. After Qiskit Aer 0.14, this will be the default behavior, so we won't need to specify this argument.\n", - "" + "This circuit contains parameters to represent the rotation angles for $R_y$ and $R_z$ gates. When simulating this circuit, we need to specify explicit values for these parameters. In the next cell, we specify some values for these parameters and use the [Estimator](https://qiskit.org/ecosystem/aer/stubs/qiskit_aer.primitives.Estimator.html) primitive from Qiskit Aer to compute the exact expectation value of the observable $ZZ \\cdots Z$." ] }, { @@ -74,7 +70,6 @@ "observable = SparsePauliOp(\"Z\" * n_qubits)\n", "params = [0.1] * circuit.num_parameters\n", "\n", - "exact_estimator = Estimator(approximation=True)\n", "job = exact_estimator.run(circuit, observable, params)\n", "exact_value = job.result().values[0]\n", "exact_value" @@ -117,7 +112,7 @@ ")\n", "\n", "noisy_estimator = Estimator(\n", - " backend_options={\"noise_model\": noise_model}, approximation=True\n", + " backend_options={\"noise_model\": noise_model}\n", ")\n", "job = noisy_estimator.run(circuit, observable, params)\n", "noisy_value = job.result().values[0]\n", From 1262a320af19ec70d1c611f7ed7427d0e0273824 Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Tue, 12 Mar 2024 14:00:27 -0400 Subject: [PATCH 02/11] Update stabilizer-circuit-simulation.ipynb --- docs/verify/stabilizer-circuit-simulation.ipynb | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/verify/stabilizer-circuit-simulation.ipynb b/docs/verify/stabilizer-circuit-simulation.ipynb index b21cd8b346b..cbdaf7b3f9c 100644 --- a/docs/verify/stabilizer-circuit-simulation.ipynb +++ b/docs/verify/stabilizer-circuit-simulation.ipynb @@ -179,7 +179,6 @@ "\n", "exact_estimator = Estimator(\n", " backend_options=dict(method=\"stabilizer\"),\n", - " approximation=True,\n", ")\n", "job = exact_estimator.run(circuit, observable, params)\n", "exact_value = job.result().values[0]\n", From a17c83becf77c7c67d161dcc39be944f26f0eca4 Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Tue, 12 Mar 2024 14:02:04 -0400 Subject: [PATCH 03/11] Update qiskit-opflow-module.mdx --- docs/api/migration-guides/qiskit-opflow-module.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/migration-guides/qiskit-opflow-module.mdx b/docs/api/migration-guides/qiskit-opflow-module.mdx index ca8343eb98d..1d711803aab 100644 --- a/docs/api/migration-guides/qiskit-opflow-module.mdx +++ b/docs/api/migration-guides/qiskit-opflow-module.mdx @@ -950,7 +950,7 @@ are different `Estimator` implementations, as noted [previously.](#attention_pri | Opflow | Alternative | | --- | --- | | [`qiskit.opflow.expectations.ExpectationFactory`](../qiskit/0.46/qiskit.opflow.expectations.ExpectationFactory) | No direct replacement. This class was used to create instances of one of the classes listed below. | -| [`qiskit.opflow.expectations.AerPauliExpectation`](../qiskit/0.46/qiskit.opflow.expectations.AerPauliExpectation) | Use [`qiskit_aer.primitives.Estimator`](https://qiskit.org/ecosystem/aer/stubs/qiskit_aer.primitives.Estimator.html) with `approximation=True`, and then `shots=None` as `run_options`. See example below. | +| [`qiskit.opflow.expectations.AerPauliExpectation`](../qiskit/0.46/qiskit.opflow.expectations.AerPauliExpectation) | Use [`qiskit_aer.primitives.Estimator`](https://qiskit.org/ecosystem/aer/stubs/qiskit_aer.primitives.Estimator.html) with `shots=None` as `run_options`. See example below. | | [`qiskit.opflow.expectations.MatrixExpectation`](../qiskit/0.46/qiskit.opflow.expectations.MatrixExpectation) | Use [`qiskit.primitives.Estimator`](../qiskit/qiskit.primitives.Estimator) primitive. If no shots are set, it performs an exact Statevector calculation. See example below. | | [`qiskit.opflow.expectations.PauliExpectation`](../qiskit/0.46/qiskit.opflow.expectations.PauliExpectation) | Use any Estimator primitive. For [`qiskit.primitives.Estimator`](../qiskit/qiskit.primitives.Estimator), set `shots!=None` for a shotbased simulation. For [`qiskit_aer.primitives.Estimator`](https://qiskit.org/ecosystem/aer/stubs/qiskit_aer.primitives.Estimator.html), this is the default. | @@ -989,7 +989,7 @@ from qiskit.quantum_info import SparsePauliOp from qiskit import QuantumCircuit from qiskit_aer.primitives import Estimator -estimator = Estimator(approximation=True, run_options={"shots": None}) +estimator = Estimator(run_options={"shots": None}) op = SparsePauliOp.from_list([("X", 1j)]) states_op = QuantumCircuit(1) From d2cfbfa2c0434978ab5834ed47149bf3b8197e98 Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Tue, 12 Mar 2024 14:02:42 -0400 Subject: [PATCH 04/11] Update qiskit-algorithms-module.mdx --- docs/api/migration-guides/qiskit-algorithms-module.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/migration-guides/qiskit-algorithms-module.mdx b/docs/api/migration-guides/qiskit-algorithms-module.mdx index e918158161b..81efd5f2987 100644 --- a/docs/api/migration-guides/qiskit-algorithms-module.mdx +++ b/docs/api/migration-guides/qiskit-algorithms-module.mdx @@ -151,7 +151,7 @@ This guide describes these common configurations for algorithms that determine w from qiskit_aer.primitives import Sampler, Estimator sampler = Sampler(run_options={"approximation": True, "shots": None}) -estimator = Estimator(run_options={"approximation": True, "shots": None}) +estimator = Estimator(run_options={"shots": None}) ``` From bb8c1775f67502d10edd38cb92fa4647ee4d1115 Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Thu, 4 Apr 2024 10:00:21 -0400 Subject: [PATCH 05/11] rmv approx=true --- docs/api/migration-guides/qiskit-algorithms-module.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/api/migration-guides/qiskit-algorithms-module.mdx b/docs/api/migration-guides/qiskit-algorithms-module.mdx index 81efd5f2987..ef22f90fcea 100644 --- a/docs/api/migration-guides/qiskit-algorithms-module.mdx +++ b/docs/api/migration-guides/qiskit-algorithms-module.mdx @@ -145,12 +145,12 @@ This guide describes these common configurations for algorithms that determine w * Running an algorithm on an Aer simulator using a custom instruction. For example, using the [`qiskit.opflow`](../qiskit/0.46/opflow) legacy [`qiskit.opflow.expectations.AerPauliExpectation`](../qiskit/0.46/qiskit.opflow.expectations.AerPauliExpectation). -- Aer Primitives with `shots=None`, `approximation=True`. See [TrotterQRTE](#trotterqrte) for examples. +- Aer Primitives with `shots=None`. See [TrotterQRTE](#trotterqrte) for examples. ```python from qiskit_aer.primitives import Sampler, Estimator -sampler = Sampler(run_options={"approximation": True, "shots": None}) +sampler = Sampler(run_options={"shots": None}) estimator = Estimator(run_options={"shots": None}) ``` @@ -706,7 +706,7 @@ time = 1 evolution_problem = TimeEvolutionProblem(operator, 1, initial_state) # Aer simulator using custom instruction -estimator = AerEstimator(run_options={"approximation": True, "shots": None}) +estimator = AerEstimator(run_options={"shots": None}) # LieTrotter with 1 rep trotter_qrte = TrotterQRTE(estimator=estimator) From 9fd46c95a8b4ba9fc5287fb02c25bc7bb675dac8 Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Thu, 4 Apr 2024 10:37:07 -0400 Subject: [PATCH 06/11] Debug help from Elena --- docs/verify/simulate-with-qiskit-aer.ipynb | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/verify/simulate-with-qiskit-aer.ipynb b/docs/verify/simulate-with-qiskit-aer.ipynb index a132d297464..81f3cac0b25 100644 --- a/docs/verify/simulate-with-qiskit-aer.ipynb +++ b/docs/verify/simulate-with-qiskit-aer.ipynb @@ -70,6 +70,7 @@ "observable = SparsePauliOp(\"Z\" * n_qubits)\n", "params = [0.1] * circuit.num_parameters\n", "\n", + "exact_estimator = Estimator()\n", "job = exact_estimator.run(circuit, observable, params)\n", "exact_value = job.result().values[0]\n", "exact_value" From e1b1caaff182ce2ac52888fa24aab9595654dd1e Mon Sep 17 00:00:00 2001 From: abbycross Date: Fri, 5 Apr 2024 17:22:08 -0400 Subject: [PATCH 07/11] Update docs/api/migration-guides/qiskit-algorithms-module.mdx Co-authored-by: Frank Harkins --- docs/api/migration-guides/qiskit-algorithms-module.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/migration-guides/qiskit-algorithms-module.mdx b/docs/api/migration-guides/qiskit-algorithms-module.mdx index ef22f90fcea..207476d841d 100644 --- a/docs/api/migration-guides/qiskit-algorithms-module.mdx +++ b/docs/api/migration-guides/qiskit-algorithms-module.mdx @@ -150,8 +150,8 @@ This guide describes these common configurations for algorithms that determine w ```python from qiskit_aer.primitives import Sampler, Estimator -sampler = Sampler(run_options={"shots": None}) -estimator = Estimator(run_options={"shots": None}) +sampler = Sampler() +estimator = Estimator() ``` From f5a9064699a8328319bbaea22380d9ea1e879df1 Mon Sep 17 00:00:00 2001 From: abbycross Date: Fri, 5 Apr 2024 17:22:27 -0400 Subject: [PATCH 08/11] Update docs/api/migration-guides/qiskit-algorithms-module.mdx Co-authored-by: Frank Harkins --- docs/api/migration-guides/qiskit-algorithms-module.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/migration-guides/qiskit-algorithms-module.mdx b/docs/api/migration-guides/qiskit-algorithms-module.mdx index 207476d841d..fffb1c58d2b 100644 --- a/docs/api/migration-guides/qiskit-algorithms-module.mdx +++ b/docs/api/migration-guides/qiskit-algorithms-module.mdx @@ -145,7 +145,7 @@ This guide describes these common configurations for algorithms that determine w * Running an algorithm on an Aer simulator using a custom instruction. For example, using the [`qiskit.opflow`](../qiskit/0.46/opflow) legacy [`qiskit.opflow.expectations.AerPauliExpectation`](../qiskit/0.46/qiskit.opflow.expectations.AerPauliExpectation). -- Aer Primitives with `shots=None`. See [TrotterQRTE](#trotterqrte) for examples. +- Aer Primitives with default options. See [TrotterQRTE](#trotterqrte) for examples. ```python from qiskit_aer.primitives import Sampler, Estimator From a58fe035a74f25db9bb42a83f32db46066efc4ca Mon Sep 17 00:00:00 2001 From: abbycross Date: Fri, 5 Apr 2024 17:22:53 -0400 Subject: [PATCH 09/11] Update docs/api/migration-guides/qiskit-algorithms-module.mdx Co-authored-by: Frank Harkins --- docs/api/migration-guides/qiskit-algorithms-module.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/migration-guides/qiskit-algorithms-module.mdx b/docs/api/migration-guides/qiskit-algorithms-module.mdx index fffb1c58d2b..8ed24f8e037 100644 --- a/docs/api/migration-guides/qiskit-algorithms-module.mdx +++ b/docs/api/migration-guides/qiskit-algorithms-module.mdx @@ -706,7 +706,7 @@ time = 1 evolution_problem = TimeEvolutionProblem(operator, 1, initial_state) # Aer simulator using custom instruction -estimator = AerEstimator(run_options={"shots": None}) +estimator = AerEstimator() # LieTrotter with 1 rep trotter_qrte = TrotterQRTE(estimator=estimator) From da2293050f2e4fce0f676aecb4aee1cbf340028e Mon Sep 17 00:00:00 2001 From: abbycross Date: Fri, 5 Apr 2024 17:23:12 -0400 Subject: [PATCH 10/11] Update docs/api/migration-guides/qiskit-opflow-module.mdx Co-authored-by: Frank Harkins --- docs/api/migration-guides/qiskit-opflow-module.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/migration-guides/qiskit-opflow-module.mdx b/docs/api/migration-guides/qiskit-opflow-module.mdx index 1d711803aab..0553f5365b5 100644 --- a/docs/api/migration-guides/qiskit-opflow-module.mdx +++ b/docs/api/migration-guides/qiskit-opflow-module.mdx @@ -950,7 +950,7 @@ are different `Estimator` implementations, as noted [previously.](#attention_pri | Opflow | Alternative | | --- | --- | | [`qiskit.opflow.expectations.ExpectationFactory`](../qiskit/0.46/qiskit.opflow.expectations.ExpectationFactory) | No direct replacement. This class was used to create instances of one of the classes listed below. | -| [`qiskit.opflow.expectations.AerPauliExpectation`](../qiskit/0.46/qiskit.opflow.expectations.AerPauliExpectation) | Use [`qiskit_aer.primitives.Estimator`](https://qiskit.org/ecosystem/aer/stubs/qiskit_aer.primitives.Estimator.html) with `shots=None` as `run_options`. See example below. | +| [`qiskit.opflow.expectations.AerPauliExpectation`](../qiskit/0.46/qiskit.opflow.expectations.AerPauliExpectation) | Use [`qiskit_aer.primitives.Estimator`](https://qiskit.org/ecosystem/aer/stubs/qiskit_aer.primitives.Estimator.html). See example below. | | [`qiskit.opflow.expectations.MatrixExpectation`](../qiskit/0.46/qiskit.opflow.expectations.MatrixExpectation) | Use [`qiskit.primitives.Estimator`](../qiskit/qiskit.primitives.Estimator) primitive. If no shots are set, it performs an exact Statevector calculation. See example below. | | [`qiskit.opflow.expectations.PauliExpectation`](../qiskit/0.46/qiskit.opflow.expectations.PauliExpectation) | Use any Estimator primitive. For [`qiskit.primitives.Estimator`](../qiskit/qiskit.primitives.Estimator), set `shots!=None` for a shotbased simulation. For [`qiskit_aer.primitives.Estimator`](https://qiskit.org/ecosystem/aer/stubs/qiskit_aer.primitives.Estimator.html), this is the default. | From 1b9dd5c38a5f2d800fe577188b7d283375c08d2a Mon Sep 17 00:00:00 2001 From: abbycross Date: Fri, 5 Apr 2024 17:23:27 -0400 Subject: [PATCH 11/11] Update docs/api/migration-guides/qiskit-opflow-module.mdx Co-authored-by: Frank Harkins --- docs/api/migration-guides/qiskit-opflow-module.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/migration-guides/qiskit-opflow-module.mdx b/docs/api/migration-guides/qiskit-opflow-module.mdx index 0553f5365b5..cbf460a9802 100644 --- a/docs/api/migration-guides/qiskit-opflow-module.mdx +++ b/docs/api/migration-guides/qiskit-opflow-module.mdx @@ -989,7 +989,7 @@ from qiskit.quantum_info import SparsePauliOp from qiskit import QuantumCircuit from qiskit_aer.primitives import Estimator -estimator = Estimator(run_options={"shots": None}) +estimator = Estimator() op = SparsePauliOp.from_list([("X", 1j)]) states_op = QuantumCircuit(1)