qiskit-aer icon indicating copy to clipboard operation
qiskit-aer copied to clipboard

Primitives support run method in Terra 0.22

Open ikkoham opened this issue 2 years ago • 2 comments

Summary

This PR depends on the following PRs. https://github.com/Qiskit/qiskit-terra/pull/8684 https://github.com/Qiskit/qiskit-terra/pull/8604 https://github.com/Qiskit/qiskit-terra/pull/8837

Once it is determined what these PRs will be, I believe merging this PR is possible even before 0.22.

Details and comments

ikkoham avatar Sep 14 '22 01:09 ikkoham

I've tagged this as stable backport potential because after terra 0.22.0 is released we'll want to get an aer 0.11.1 out to include this so we can keep Aer's primitive implementation compatible with the API changes to the sampler and estimator

mtreinish avatar Sep 30 '22 15:09 mtreinish

need to test 0.22 (or 0.22RC)

ikkoham avatar Oct 11 '22 12:10 ikkoham

This PR is necessary to pass lint tests since 0.22 was released.

hhorii avatar Oct 17 '22 05:10 hhorii

A test is failed with terra 0.22:

test.terra.primitives.test_estimator.TestEstimator.test_passing_objects
-----------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/home/runner/work/qiskit-aer/qiskit-aer/test/terra/primitives/test_estimator.py", line 326, in test_passing_objects
    with Estimator([self.ansatz], [self.observable]) as estimator:

      File "/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/qiskit_aer/primitives/estimator.py", line 98, in __init__
    super().__init__(

      File "/opt/hostedtoolcache/Python/3.10.7/x64/lib/python3.10/site-packages/qiskit/primitives/base/base_estimator.py", line 136, in __init__
    warn(

    DeprecationWarning: The BaseEstimator `circuits`, `observables`, `parameters` kwarg are deprecated as of Qiskit Terra 0.22.0 and will be removed no earlier than 3 months after the release date. You can use the 'run' method to append objects.

@ikkoham reproduced this test error with following code since https://github.com/Qiskit/qiskit-terra/pull/8615:

from qiskit import QuantumCircuit, transpile

from qiskit_aer.noise import RelaxationNoisePass

qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])

durations = [("h", None, 10), ("cx", None, 50), ("measure", None, 200)]
sched_circ = transpile(qc, scheduling_method='alap', instruction_durations=durations)

noise_pass = RelaxationNoisePass(t1s=[0.10, 0.11], t2s=[0.20, 0.21], dt=0.01)
noisy_circ = noise_pass(sched_circ)

noisy_circ.decompose()

To pass the CI tests, both of this PR and a fix for above are necessary. Or @ikkoham can disable the test test.terra.primitives.test_estimator.TestEstimator.test_passing_objects by creating an issue for it.

hhorii avatar Oct 18 '22 12:10 hhorii