Closed caleb-johnson closed 5 months ago
nb: The relevant function is reconstruct_expectation_values
in https://github.com/Qiskit-Extensions/circuit-knitting-toolbox/blob/main/circuit_knitting/cutting/cutting_reconstruction.py.
For more info on the migration, see https://docs.quantum.ibm.com/api/migration-guides/qiskit-1.0-features#qiskitprimitives and https://github.com/Qiskit/qiskit-ibm-runtime?tab=readme-ov-file#primitive-versions.
Tracking issue from Qiskit Aer to support primitives V2: https://github.com/Qiskit/qiskit-aer/issues/2078
EDIT: Actually, there's no reason to wait on Aer to add support for primitives V2, but we might want to wait on Aer before we adopt the new primitives entirely. I've opened #503 as a follow up to this issue for that reason.
Actually (reversing course a second time), it seems like we do indeed need to wait for Aer to support SamplerV2 if we are to provide automated tests of this feature, because Qiskit's implemention throws an error: "StatevectorSampler cannot handle mid-circuit measurements
". Unless, of course, we want to provide our own BaseSamplerV2
implementation based on our simulation.py
-- but I think we are better off waiting on Aer.
it seems like we do indeed need to wait for Aer to support SamplerV2 if we are to provide automated tests of this feature
Then again, we can provide a smoke test by only executing the circuits that do not contain any mid-circuit measurements. This might be worth doing, as long as we also manually test the code using Qiskit Runtime.
An alternative would be to use BackendSamplerV2
together with AerSimulator
, as suggested at https://github.com/Qiskit/qiskit-aer/issues/2078. But this would mean waiting for Qiskit 1.1 (which is when BackendSamplerV2
will first appear in a release) and will also require a fix to https://github.com/Qiskit/qiskit/issues/12043.
The circuit cutting post-processing uses the
SamplerResult
objects output fromSamplerV1
directly; however,SamplerV2
will returnPrimitiveResult
objects, so our post-processing should support both types of outputs from the two different sampler interfaceshttps://github.com/Qiskit/qiskit/blob/61181ce0681129f9a1d5af43122484f8b6da1bbc/qiskit/primitives/base/base_sampler.py#L231