Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After Aer .14 is released, remove approximation=true from relevant pages #1020

Merged
merged 11 commits into from
Apr 8, 2024
2 changes: 1 addition & 1 deletion docs/api/migration-guides/qiskit-algorithms-module.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinsung the change is only for Estimator, not Sampler, correct? Should I leave this line as-is?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, "approximation" is not a valid run option, so I think it can be removed immediately from all examples of Sampler and Estimator. See Qiskit/qiskit-aer#2083 though.

#319 Refers to passing approximation=True directly to the initializer of Estimator, as in those pages in the verify section.

estimator = Estimator(run_options={"approximation": True, "shots": None})
estimator = Estimator(run_options={"shots": None})
```

<span id="eigen"></span>
Expand Down
4 changes: 2 additions & 2 deletions docs/api/migration-guides/qiskit-opflow-module.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
abbycross marked this conversation as resolved.
Show resolved Hide resolved
| [`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. |

Expand Down Expand Up @@ -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})
abbycross marked this conversation as resolved.
Show resolved Hide resolved

op = SparsePauliOp.from_list([("X", 1j)])
states_op = QuantumCircuit(1)
Expand Down
9 changes: 2 additions & 7 deletions docs/verify/simulate-with-qiskit-aer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"<Admonition type=\"note\">\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",
"</Admonition>"
"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$."
]
},
{
Expand All @@ -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"
Expand Down Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion docs/verify/stabilizer-circuit-simulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading