diff --git a/qiskit_ibm_runtime/sampler.py b/qiskit_ibm_runtime/sampler.py index c1129b406..c92d4f8b3 100644 --- a/qiskit_ibm_runtime/sampler.py +++ b/qiskit_ibm_runtime/sampler.py @@ -90,10 +90,8 @@ def __init__( Sampler.__init__(self) BasePrimitiveV2.__init__(self, backend=backend, session=session, options=options) - raise NotImplementedError("SamplerV2 is not currently supported.") - - # if self._service._channel_strategy == "q-ctrl": - # raise NotImplementedError("SamplerV2 is not supported with q-ctrl channel strategy.") + if self._service._channel_strategy == "q-ctrl": + raise NotImplementedError("SamplerV2 is not supported with q-ctrl channel strategy.") def run(self, pubs: Iterable[SamplerPubLike], *, shots: int | None = None) -> RuntimeJob: """Submit a request to the estimator primitive. diff --git a/qiskit_ibm_runtime/utils/sampler_result_decoder.py b/qiskit_ibm_runtime/utils/sampler_result_decoder.py index 626f45ee4..fa68339d0 100644 --- a/qiskit_ibm_runtime/utils/sampler_result_decoder.py +++ b/qiskit_ibm_runtime/utils/sampler_result_decoder.py @@ -12,11 +12,12 @@ """Sampler result decoder.""" -from typing import Dict +from typing import Dict, Union from math import sqrt from qiskit.result import QuasiDistribution from qiskit.primitives import SamplerResult +from qiskit.primitives import PrimitiveResult from .result_decoder import ResultDecoder @@ -25,9 +26,16 @@ class SamplerResultDecoder(ResultDecoder): """Class used to decode sampler results.""" @classmethod - def decode(cls, raw_result: str) -> SamplerResult: + def decode(cls, raw_result: str) -> Union[SamplerResult, PrimitiveResult]: """Convert the result to SamplerResult.""" decoded: Dict = super().decode(raw_result) + + if isinstance(decoded, PrimitiveResult): + return decoded + + # TODO: Handle V2 result that is returned in dict format + + # V1 result quasi_dists = [] for quasi, meta in zip(decoded["quasi_dists"], decoded["metadata"]): shots = meta.get("shots", float("inf"))