Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions azure-quantum/azure/quantum/qiskit/backends/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion azure-quantum/azure/quantum/qiskit/backends/rigetti.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down
8 changes: 4 additions & 4 deletions azure-quantum/azure/quantum/qiskit/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion azure-quantum/azure/quantum/target/quantinuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Quantinuum(Target):
"quantinuum.sim.h2-2e",
)

_SHOTS_PARAM_NAME = "count"
_SHOTS_PARAM_NAME = "shots"

def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion azure-quantum/azure/quantum/target/rigetti/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 2 additions & 5 deletions azure-quantum/tests/test_qiskit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand All @@ -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",
Expand All @@ -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"

Expand Down
Loading