Skip to content

Commit

Permalink
Use Aer's SamplerV2 instead of SamplerV1 (#643)
Browse files Browse the repository at this point in the history
* Use Aer's SamplerV2 instead of SamplerV1

Addresses part of #506

* `qiskit_aer.primitives.SamplerV2` does not support mid-circuit measurements

so we use runtime `SamplerV2` with `AerSimulator` as the backend instead
  • Loading branch information
garrison authored Jul 17, 2024
1 parent 19b6a52 commit b4db37e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 4 additions & 1 deletion test/cutting/test_cutting_roundtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
)
from qiskit.quantum_info import PauliList, random_unitary
from qiskit.primitives import Estimator
from qiskit_ibm_runtime import SamplerV2
from qiskit_aer import AerSimulator
from qiskit_aer.primitives import Sampler

from circuit_knitting.utils.simulation import ExactSampler
Expand Down Expand Up @@ -172,7 +174,8 @@ def test_cutting_exact_reconstruction(example_circuit):


@pytest.mark.parametrize(
"sampler,is_exact_sampler", [(Sampler(), False), (ExactSampler(), True)]
"sampler,is_exact_sampler",
[(Sampler(), False), (SamplerV2(AerSimulator()), False), (ExactSampler(), True)],
)
def test_sampler_with_identity_subobservable(sampler, is_exact_sampler):
"""This test ensures that the sampler works for a subcircuit with no observable measurements.
Expand Down
7 changes: 3 additions & 4 deletions test/cutting/test_cutting_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit.providers.fake_provider import GenericBackendV2
from qiskit_ibm_runtime import SamplerV2
from qiskit_aer.primitives import Sampler
from qiskit_aer import AerSimulator

from circuit_knitting.cutting.qpd.instructions import SingleQubitQPDGate
Expand Down Expand Up @@ -89,11 +88,11 @@ def test_exotic_labels(label1, label2):
assert subexperiments.keys() == subcircuits.keys()

samplers = {
label1: Sampler(run_options={"shots": 10}),
label2: Sampler(run_options={"shots": 10}),
label1: SamplerV2(AerSimulator()),
label2: SamplerV2(AerSimulator()),
}
results = {
label: sampler.run(subexperiments[label]).result()
label: sampler.run(subexperiments[label], shots=10).result()
for label, sampler in samplers.items()
}

Expand Down

0 comments on commit b4db37e

Please sign in to comment.