From f4cd826c2d1a6d731236d1c7998ae66ace6cac35 Mon Sep 17 00:00:00 2001 From: Xinyi Joffre Date: Wed, 11 Feb 2026 13:30:18 -0800 Subject: [PATCH 1/3] Align most QIR providers to "shots" parameter --- azure-quantum/azure/quantum/qiskit/backends/backend.py | 8 +------- azure-quantum/azure/quantum/qiskit/backends/quantinuum.py | 2 +- azure-quantum/azure/quantum/qiskit/backends/rigetti.py | 2 +- azure-quantum/azure/quantum/qiskit/job.py | 8 ++++---- azure-quantum/azure/quantum/target/quantinuum.py | 2 +- azure-quantum/azure/quantum/target/rigetti/target.py | 2 +- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/azure-quantum/azure/quantum/qiskit/backends/backend.py b/azure-quantum/azure/quantum/qiskit/backends/backend.py index 0ca46fc04..5d3e13749 100644 --- a/azure-quantum/azure/quantum/qiskit/backends/backend.py +++ b/azure-quantum/azure/quantum/qiskit/backends/backend.py @@ -290,7 +290,7 @@ class AzureBackendBase(Backend, SessionHost): # Name of the provider's input parameter which specifies number of shots for a submitted job. # If None, backend will not pass this input parameter. - _SHOTS_PARAM_NAME = None + _SHOTS_PARAM_NAME = "shots" @abstractmethod def __init__( @@ -451,12 +451,6 @@ def _get_input_params(self, options: Dict[str, Any], shots: int = None) -> Dict[ if final_shots is None: final_shots = input_params.get(self.__class__._SHOTS_PARAM_NAME) - # Also add all possible shots options into input_params to make sure - # that all backends covered. - # TODO: Double check all backends for shots options in order to remove this extra check. - input_params["shots"] = final_shots - input_params["count"] = final_shots - # Safely removing "shots" and "count" from options as they will be passed in input_params now. _ = options.pop("shots", None) _ = options.pop("count", None) diff --git a/azure-quantum/azure/quantum/qiskit/backends/quantinuum.py b/azure-quantum/azure/quantum/qiskit/backends/quantinuum.py index 2ed514e18..a08d67945 100644 --- a/azure-quantum/azure/quantum/qiskit/backends/quantinuum.py +++ b/azure-quantum/azure/quantum/qiskit/backends/quantinuum.py @@ -67,7 +67,7 @@ def _get_n_qubits(name): UserWarning(f"Number of qubits not known for target {name}. Defaulting to 20.")) return 20 -_QUANTINUUM_COUNT_INPUT_PARAM_NAME = "count" +_QUANTINUUM_COUNT_INPUT_PARAM_NAME = "shots" _DEFAULT_SHOTS_COUNT = 500 class QuantinuumQirBackendBase(AzureQirBackend): diff --git a/azure-quantum/azure/quantum/qiskit/backends/rigetti.py b/azure-quantum/azure/quantum/qiskit/backends/rigetti.py index 0c98b34b7..3d1c125cd 100644 --- a/azure-quantum/azure/quantum/qiskit/backends/rigetti.py +++ b/azure-quantum/azure/quantum/qiskit/backends/rigetti.py @@ -26,7 +26,7 @@ class RigettiBackend(AzureQirBackend): """Base class for interfacing with a Rigetti backend in Azure Quantum""" - _SHOTS_PARAM_NAME = "count" + _SHOTS_PARAM_NAME = "shots" @abstractmethod def __init__( diff --git a/azure-quantum/azure/quantum/qiskit/job.py b/azure-quantum/azure/quantum/qiskit/job.py index e9fcd6b8f..beb55b99d 100644 --- a/azure-quantum/azure/quantum/qiskit/job.py +++ b/azure-quantum/azure/quantum/qiskit/job.py @@ -115,14 +115,14 @@ def queue_position(self): return None def _shots_count(self): - # Some providers use 'count', some other 'shots', give preference to 'count': + # Some providers use 'count', some other 'shots', give preference to 'shots': input_params = self._azure_job.details.input_params options = self.backend().options shots = \ - input_params["count"] if "count" in input_params else \ input_params["shots"] if "shots" in input_params else \ - options.get("count") if "count" in vars(options) else \ - options.get("shots") + input_params["count"] if "count" in input_params else \ + options.get("shots") if "shots" in vars(options) else \ + options.get("count") return shots diff --git a/azure-quantum/azure/quantum/target/quantinuum.py b/azure-quantum/azure/quantum/target/quantinuum.py index eeb72c767..9be7b46e0 100644 --- a/azure-quantum/azure/quantum/target/quantinuum.py +++ b/azure-quantum/azure/quantum/target/quantinuum.py @@ -22,7 +22,7 @@ class Quantinuum(Target): "quantinuum.sim.h2-2e", ) - _SHOTS_PARAM_NAME = "count" + _SHOTS_PARAM_NAME = "shots" def __init__( self, diff --git a/azure-quantum/azure/quantum/target/rigetti/target.py b/azure-quantum/azure/quantum/target/rigetti/target.py index fb13e5dfa..227901192 100644 --- a/azure-quantum/azure/quantum/target/rigetti/target.py +++ b/azure-quantum/azure/quantum/target/rigetti/target.py @@ -130,7 +130,7 @@ class Rigetti(Target): target_names = tuple(target.value for target in RigettiTarget) - _SHOTS_PARAM_NAME = "count" + _SHOTS_PARAM_NAME = "shots" def __init__( self, From a06d5f1248a5ff235ac452783afec0fd01911807 Mon Sep 17 00:00:00 2001 From: Xinyi Joffre Date: Wed, 11 Feb 2026 13:33:33 -0800 Subject: [PATCH 2/3] Fix unit tests --- azure-quantum/tests/test_qiskit.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/azure-quantum/tests/test_qiskit.py b/azure-quantum/tests/test_qiskit.py index 2cb349c44..1059b8dc9 100644 --- a/azure-quantum/tests/test_qiskit.py +++ b/azure-quantum/tests/test_qiskit.py @@ -254,9 +254,8 @@ def test_quantinuum_request_construction_offline(monkeypatch: pytest.MonkeyPatch provider = AzureQuantumProvider(workspace=ws) backend = QuantinuumEmulatorBackend(name="quantinuum.sim.h2-1e", provider=provider) - # Quantinuum uses `count` as the provider-specific shots input param. with pytest.warns(UserWarning, match="conflicts"): - input_params = backend._get_input_params({"count": 999}, shots=123) + input_params = backend._get_input_params({"shots": 999}, shots=123) job = backend._run( job_name="offline-quantinuum", @@ -277,7 +276,6 @@ def test_quantinuum_request_construction_offline(monkeypatch: pytest.MonkeyPatch assert details.target == "quantinuum.sim.h2-1e" assert details.input_data_format == "honeywell.openqasm.v1" assert details.output_data_format == "honeywell.quantum-results.v1" - assert details.input_params["count"] == 123 assert details.input_params["shots"] == 123 assert details.metadata.get("foo") == "bar" assert details.metadata.get("meta") == "value" @@ -295,7 +293,7 @@ def test_rigetti_request_construction_offline(monkeypatch: pytest.MonkeyPatch): backend = RigettiSimulatorBackend(name=RigettiTarget.QVM.value, provider=provider) with pytest.warns(UserWarning, match="subject to change"): - input_params = backend._get_input_params({"count": 10}, shots=None) + input_params = backend._get_input_params({"shots": 10}, shots=None) job = backend._run( job_name="offline-rigetti", @@ -315,7 +313,6 @@ def test_rigetti_request_construction_offline(monkeypatch: pytest.MonkeyPatch): assert details.provider_id == "rigetti" assert details.input_data_format == "qir.v1" assert details.output_data_format == "microsoft.quantum-results.v2" - assert details.input_params["count"] == 10 assert details.input_params["shots"] == 10 assert details.metadata.get("foo") == "bar" From 8ffb17cb11ee487788a6b9e71b42480b5e04d6f4 Mon Sep 17 00:00:00 2001 From: Zulfat Nutfullin Date: Thu, 12 Feb 2026 11:09:16 -0800 Subject: [PATCH 3/3] Remove deprecation message if user still provides 'count' (#720) * Fix tests * Remove count param handling for ionq and qci * Revert "Fix tests" This reverts commit e9837976116221ed4e69048d8afcc17306a2c59d. --- .../azure/quantum/qiskit/backends/backend.py | 26 ------------------ .../azure/quantum/qiskit/backends/ionq.py | 27 ++----------------- .../azure/quantum/qiskit/backends/qci.py | 14 +--------- 3 files changed, 3 insertions(+), 64 deletions(-) diff --git a/azure-quantum/azure/quantum/qiskit/backends/backend.py b/azure-quantum/azure/quantum/qiskit/backends/backend.py index 5d3e13749..acdbc34f9 100644 --- a/azure-quantum/azure/quantum/qiskit/backends/backend.py +++ b/azure-quantum/azure/quantum/qiskit/backends/backend.py @@ -824,29 +824,3 @@ def run( logger.info(input_data) return job - -def _get_shots_or_deprecated_count_input_param( - param_name: str, - shots: int = None, - count: int = None, - ) -> Optional[int]: - """ - This helper function checks if the deprecated 'count' option is specified. - In earlier versions it was possible to pass this option to specify shots number for a job, - but now we only check for it for compatibility reasons. - """ - - final_shots = None - - if shots is not None: - final_shots = shots - - elif count is not None: - final_shots = count - warnings.warn( - "The 'count' parameter will be deprecated. " - f"Please, use '{param_name}' parameter instead.", - category=DeprecationWarning, - ) - - return final_shots \ No newline at end of file diff --git a/azure-quantum/azure/quantum/qiskit/backends/ionq.py b/azure-quantum/azure/quantum/qiskit/backends/ionq.py index 132d05e47..99c888928 100644 --- a/azure-quantum/azure/quantum/qiskit/backends/ionq.py +++ b/azure-quantum/azure/quantum/qiskit/backends/ionq.py @@ -15,7 +15,6 @@ AzureBackendConfig, AzureQirBackend, _ensure_backend_config, - _get_shots_or_deprecated_count_input_param, ) from qiskit.providers import Options @@ -84,18 +83,7 @@ def run( shots: int = None, **options, ) -> AzureQuantumJob: - - # In earlier versions, backends for all providers accepted the 'count' option, - # but now we accept it only for a compatibility reasons and do not recommend using it. - count = options.pop("count", None) - - final_shots = _get_shots_or_deprecated_count_input_param( - param_name=self.__class__._SHOTS_PARAM_NAME, - shots=shots, - count=count, - ) - - return super().run(run_input, shots=final_shots, **options) + return super().run(run_input, shots=shots, **options) class IonQSimulatorQirBackend(IonQQirBackendBase): @@ -207,18 +195,7 @@ def run( shots: int = None, **options, ) -> AzureQuantumJob: - - # In earlier versions, backends for all providers accepted the 'count' option, - # but now we accept it only for a compatibility reasons and do not recommend using it. - count = options.pop("count", None) - - final_shots = _get_shots_or_deprecated_count_input_param( - param_name=self.__class__._SHOTS_PARAM_NAME, - shots=shots, - count=count, - ) - - return super().run(run_input, shots=final_shots, **options) + return super().run(run_input, shots=shots, **options) @classmethod def _default_options(cls): diff --git a/azure-quantum/azure/quantum/qiskit/backends/qci.py b/azure-quantum/azure/quantum/qiskit/backends/qci.py index 1d500150a..04cc8c6b2 100644 --- a/azure-quantum/azure/quantum/qiskit/backends/qci.py +++ b/azure-quantum/azure/quantum/qiskit/backends/qci.py @@ -11,7 +11,6 @@ AzureBackendConfig, AzureQirBackend, _ensure_backend_config, - _get_shots_or_deprecated_count_input_param, ) from qiskit.providers import Options from qsharp import TargetProfile @@ -66,18 +65,7 @@ def run( shots: int = None, **options, ) -> AzureQuantumJob: - - # In earlier versions, backends for all providers accepted the 'count' option, - # but now we accept it only for a compatibility reasons and do not recommend using it. - count = options.pop("count", None) - - final_shots = _get_shots_or_deprecated_count_input_param( - param_name=self.__class__._SHOTS_PARAM_NAME, - shots=shots, - count=count, - ) - - return super().run(run_input, shots=final_shots, **options) + return super().run(run_input, shots=shots, **options) class QCISimulatorBackend(QCIBackend):