Skip to content

Commit

Permalink
After Aer .14 is released, remove approximation=true from relevant pa…
Browse files Browse the repository at this point in the history
…ges (Qiskit#1020)

Closes Qiskit#319

---------

Co-authored-by: Frank Harkins <frankharkins@hotmail.co.uk>
  • Loading branch information
abbycross and frankharkins authored Apr 8, 2024
1 parent 9d0ad60 commit 9183570
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
8 changes: 4 additions & 4 deletions docs/api/migration-guides/qiskit-algorithms-module.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ 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 default options. See [TrotterQRTE](#trotterqrte) for examples.

```python
from qiskit_aer.primitives import Sampler, Estimator

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

<span id="eigen"></span>
Expand Down Expand Up @@ -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()

# LieTrotter with 1 rep
trotter_qrte = TrotterQRTE(estimator=estimator)
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). 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. |

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()

op = SparsePauliOp.from_list([("X", 1j)])
states_op = QuantumCircuit(1)
Expand Down
10 changes: 3 additions & 7 deletions docs/verify/simulate-with-qiskit-aer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,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 @@ -80,7 +76,7 @@
"observable = SparsePauliOp(\"Z\" * n_qubits)\n",
"params = [0.1] * circuit.num_parameters\n",
"\n",
"exact_estimator = Estimator(approximation=True)\n",
"exact_estimator = Estimator()\n",
"job = exact_estimator.run(circuit, observable, params)\n",
"exact_value = job.result().values[0]\n",
"exact_value"
Expand Down Expand Up @@ -123,7 +119,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 @@ -181,7 +181,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

0 comments on commit 9183570

Please sign in to comment.