Skip to content

Commit

Permalink
Return only default backends by the Qiskit provider (#602)
Browse files Browse the repository at this point in the history
* qiskit provider now returns only default backends
  • Loading branch information
ArthurKamalov authored Apr 23, 2024
1 parent 01e288a commit 0699fa5
Show file tree
Hide file tree
Showing 118 changed files with 42,879 additions and 18,964 deletions.
1 change: 1 addition & 0 deletions azure-quantum/azure/quantum/qiskit/backends/microsoft.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
{"name": "TODO", "parameters": [], "qasm_def": "TODO"}
], # NOTE: copied from other backends
"azure": self._azure_config(),
"is_default": True,
}
)
logger.info("Initializing MicrosoftResourceEstimationBackend")
Expand Down
2 changes: 2 additions & 0 deletions azure-quantum/azure/quantum/qiskit/backends/qci.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"open_pulse": False,
"gates": [{"name": "TODO", "parameters": [], "qasm_def": "TODO"}],
"azure": self._azure_config(),
"is_default": True,
}
)
logger.info("Initializing QCISimulatorBackend")
Expand Down Expand Up @@ -150,6 +151,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"open_pulse": False,
"gates": [{"name": "TODO", "parameters": [], "qasm_def": "TODO"}],
"azure": self._azure_config(),
"is_default": True,
}
)
logger.info("Initializing QCIQPUBackend")
Expand Down
2 changes: 2 additions & 0 deletions azure-quantum/azure/quantum/qiskit/backends/rigetti.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"open_pulse": False,
"gates": [{"name": "TODO", "parameters": [], "qasm_def": "TODO"}],
"azure": self._azure_config(),
"is_default": True,
}
)
logger.info("Initializing RigettiSimulatorBackend")
Expand Down Expand Up @@ -125,6 +126,7 @@ def __init__(self, name: str, provider: "AzureQuantumProvider", **kwargs):
"open_pulse": False,
"gates": [{"name": "TODO", "parameters": [], "qasm_def": "TODO"}],
"azure": self._azure_config(),
"is_default": True,
}
)
logger.info("Initializing RigettiQPUBackend")
Expand Down
34 changes: 16 additions & 18 deletions azure-quantum/azure/quantum/qiskit/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,6 @@ def get_backend(self, name=None, **kwargs) -> AzureBackendBase:

backends = self.backends(name=name, **kwargs)

if len(backends) > 1:
def all_same(iterable):
group_iter = groupby(iterable)
return next(group_iter, True) and not next(group_iter, False)

# If all backends have the same name, filter for default backend
if all_same(backend.name() for backend in backends):
backends = list(
filter(
lambda backend: self._match_all(
backend.configuration().to_dict(), {"is_default": True}
),
backends,
)
)

if len(backends) > 1:
raise QiskitBackendNotFoundError(
"More than one backend matches the criteria"
Expand Down Expand Up @@ -132,11 +116,25 @@ def backends(self, name=None, **kwargs):
backend_list = [x for v in self._backends.values() for x in v]

# filter by properties specified in the kwargs and filter function
backends: List[Backend] = self._filter_backends(
filtered_backends: List[Backend] = self._filter_backends(
backend_list, filters=workspace_allowed, **kwargs
)

return backends
# Also filter out non-default backends.
default_backends = list(
filter(
lambda backend: self._match_all(
backend.configuration().to_dict(), {"is_default": True}
),
filtered_backends,
)
)
# If default backends were found - return them, otherwise return the filtered_backends collection.
# The latter case could happen where there's no default backend defined for the specified target.
if len(default_backends) > 0:
return default_backends

return filtered_backends

def get_job(self, job_id) -> AzureQuantumJob:
"""Returns the Job instance associated with the given id.
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

219 changes: 124 additions & 95 deletions azure-quantum/tests/unit/recordings/test_dft_failure_invalid_input.yaml

Large diffs are not rendered by default.

442 changes: 207 additions & 235 deletions azure-quantum/tests/unit/recordings/test_dft_success.yaml

Large diffs are not rendered by default.

217 changes: 153 additions & 64 deletions azure-quantum/tests/unit/recordings/test_estimator_batching_job.yaml

Large diffs are not rendered by default.

94 changes: 47 additions & 47 deletions azure-quantum/tests/unit/recordings/test_estimator_failing_job.yaml

Large diffs are not rendered by default.

214 changes: 140 additions & 74 deletions azure-quantum/tests/unit/recordings/test_estimator_non_batching_job.yaml

Large diffs are not rendered by default.

161 changes: 96 additions & 65 deletions azure-quantum/tests/unit/recordings/test_estimator_profiling_job.yaml

Large diffs are not rendered by default.

131 changes: 62 additions & 69 deletions azure-quantum/tests/unit/recordings/test_estimator_qiskit_job.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
interactions:
- request:
body: client_id=PLACEHOLDER&grant_type=client_credentials&client_info=1&client_secret=PLACEHOLDER&scope=https%3A%2F%2Fquantum.microsoft.com%2F.default
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '144'
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- azsdk-python-identity/1.15.0 Python/3.9.18 (Windows-10-10.0.22621-SP0)
x-client-current-telemetry:
- 4|730,2|
x-client-os:
- win32
x-client-sku:
- MSAL.Python
x-client-ver:
- 1.26.0
method: POST
uri: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000/oauth2/v2.0/token
response:
body:
string: '{"token_type": "Bearer", "expires_in": 1745372990, "ext_expires_in":
1745372990, "refresh_in": 31536000, "access_token": "PLACEHOLDER"}'
headers:
content-length:
- '135'
content-type:
- application/json; charset=utf-8
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- testapp-azure-quantum-qiskit azsdk-python-quantum/0.0.1 Python/3.9.18 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://eastus.quantum.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Quantum/workspaces/myworkspace/providerStatus?api-version=2022-09-12-preview&test-sequence-id=1
response:
body:
string: '{"value": [{"id": "microsoft-elements", "currentAvailability": "Available",
"targets": [{"id": "microsoft.dft", "currentAvailability": "Available", "averageQueueTime":
0, "statusPage": null}]}, {"id": "ionq", "currentAvailability": "Degraded",
"targets": [{"id": "ionq.qpu", "currentAvailability": "Unavailable", "averageQueueTime":
591243, "statusPage": "https://status.ionq.co"}, {"id": "ionq.qpu.aria-1",
"currentAvailability": "Available", "averageQueueTime": 525439, "statusPage":
"https://status.ionq.co"}, {"id": "ionq.qpu.aria-2", "currentAvailability":
"Unavailable", "averageQueueTime": 0, "statusPage": "https://status.ionq.co"},
{"id": "ionq.simulator", "currentAvailability": "Available", "averageQueueTime":
0, "statusPage": "https://status.ionq.co"}]}, {"id": "microsoft-qc", "currentAvailability":
"Available", "targets": [{"id": "microsoft.estimator", "currentAvailability":
"Available", "averageQueueTime": 0, "statusPage": null}]}, {"id": "pasqal",
"currentAvailability": "Degraded", "targets": [{"id": "pasqal.sim.emu-tn",
"currentAvailability": "Available", "averageQueueTime": 318, "statusPage":
"https://pasqal.com"}, {"id": "pasqal.qpu.fresnel", "currentAvailability":
"Degraded", "averageQueueTime": 0, "statusPage": "https://pasqal.com"}]},
{"id": "rigetti", "currentAvailability": "Degraded", "targets": [{"id": "rigetti.sim.qvm",
"currentAvailability": "Available", "averageQueueTime": 5, "statusPage": "https://rigetti.statuspage.io/"},
{"id": "rigetti.qpu.ankaa-2", "currentAvailability": "Degraded", "averageQueueTime":
5, "statusPage": "https://rigetti.statuspage.io/"}]}, {"id": "qci", "currentAvailability":
"Degraded", "targets": [{"id": "qci.simulator", "currentAvailability": "Available",
"averageQueueTime": 1, "statusPage": "https://quantumcircuits.com"}, {"id":
"qci.machine1", "currentAvailability": "Unavailable", "averageQueueTime":
1, "statusPage": "https://quantumcircuits.com"}, {"id": "qci.simulator.noisy",
"currentAvailability": "Available", "averageQueueTime": 0, "statusPage": "https://quantumcircuits.com"}]},
{"id": "quantinuum", "currentAvailability": "Degraded", "targets": [{"id":
"quantinuum.qpu.h1-1", "currentAvailability": "Degraded", "averageQueueTime":
0, "statusPage": "https://www.quantinuum.com/hardware/h1"}, {"id": "quantinuum.sim.h1-1sc",
"currentAvailability": "Available", "averageQueueTime": 3, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.sim.h1-1e", "currentAvailability": "Available", "averageQueueTime":
7, "statusPage": "https://www.quantinuum.com/hardware/h1"}, {"id": "quantinuum.qpu.h2-1",
"currentAvailability": "Degraded", "averageQueueTime": 0, "statusPage": "https://www.quantinuum.com/hardware/h2"},
{"id": "quantinuum.sim.h2-1sc", "currentAvailability": "Available", "averageQueueTime":
0, "statusPage": "https://www.quantinuum.com/hardware/h2"}, {"id": "quantinuum.sim.h2-1e",
"currentAvailability": "Available", "averageQueueTime": 21291, "statusPage":
"https://www.quantinuum.com/hardware/h2"}, {"id": "quantinuum.sim.h1-1sc-preview",
"currentAvailability": "Available", "averageQueueTime": 3, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.sim.h1-1e-preview", "currentAvailability": "Available",
"averageQueueTime": 7, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.sim.h1-2e-preview", "currentAvailability": "Available",
"averageQueueTime": 0, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.qpu.h1-1-preview", "currentAvailability": "Degraded", "averageQueueTime":
0, "statusPage": "https://www.quantinuum.com/hardware/h1"}]}, {"id": "Microsoft.Test",
"currentAvailability": "Available", "targets": [{"id": "echo-rigetti", "currentAvailability":
"Available", "averageQueueTime": 1, "statusPage": ""}, {"id": "echo-quantinuum",
"currentAvailability": "Available", "averageQueueTime": 1, "statusPage": ""},
{"id": "echo-qci", "currentAvailability": "Available", "averageQueueTime":
1, "statusPage": ""}, {"id": "echo-ionq", "currentAvailability": "Available",
"averageQueueTime": 1, "statusPage": ""}, {"id": "echo-aquarius", "currentAvailability":
"Available", "averageQueueTime": 1, "statusPage": ""}, {"id": "sparse-sim-rigetti",
"currentAvailability": "Available", "averageQueueTime": 1, "statusPage": ""},
{"id": "sparse-sim-quantinuum", "currentAvailability": "Available", "averageQueueTime":
1, "statusPage": ""}, {"id": "sparse-sim-qci", "currentAvailability": "Available",
"averageQueueTime": 1, "statusPage": ""}, {"id": "sparse-sim-ionq", "currentAvailability":
"Available", "averageQueueTime": 1, "statusPage": ""}, {"id": "echo-output",
"currentAvailability": "Available", "averageQueueTime": 1, "statusPage": ""}]}],
"nextLink": null}'
headers:
connection:
- keep-alive
content-length:
- '4754'
content-type:
- application/json; charset=utf-8
transfer-encoding:
- chunked
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- testapp-azure-quantum-qiskit azsdk-python-quantum/0.0.1 Python/3.9.18 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://eastus.quantum.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Quantum/workspaces/myworkspace/providerStatus?api-version=2022-09-12-preview&test-sequence-id=2
response:
body:
string: '{"value": [{"id": "microsoft-elements", "currentAvailability": "Available",
"targets": [{"id": "microsoft.dft", "currentAvailability": "Available", "averageQueueTime":
0, "statusPage": null}]}, {"id": "ionq", "currentAvailability": "Degraded",
"targets": [{"id": "ionq.qpu", "currentAvailability": "Unavailable", "averageQueueTime":
591243, "statusPage": "https://status.ionq.co"}, {"id": "ionq.qpu.aria-1",
"currentAvailability": "Available", "averageQueueTime": 525439, "statusPage":
"https://status.ionq.co"}, {"id": "ionq.qpu.aria-2", "currentAvailability":
"Unavailable", "averageQueueTime": 0, "statusPage": "https://status.ionq.co"},
{"id": "ionq.simulator", "currentAvailability": "Available", "averageQueueTime":
0, "statusPage": "https://status.ionq.co"}]}, {"id": "microsoft-qc", "currentAvailability":
"Available", "targets": [{"id": "microsoft.estimator", "currentAvailability":
"Available", "averageQueueTime": 0, "statusPage": null}]}, {"id": "pasqal",
"currentAvailability": "Degraded", "targets": [{"id": "pasqal.sim.emu-tn",
"currentAvailability": "Available", "averageQueueTime": 318, "statusPage":
"https://pasqal.com"}, {"id": "pasqal.qpu.fresnel", "currentAvailability":
"Degraded", "averageQueueTime": 0, "statusPage": "https://pasqal.com"}]},
{"id": "rigetti", "currentAvailability": "Degraded", "targets": [{"id": "rigetti.sim.qvm",
"currentAvailability": "Available", "averageQueueTime": 5, "statusPage": "https://rigetti.statuspage.io/"},
{"id": "rigetti.qpu.ankaa-2", "currentAvailability": "Degraded", "averageQueueTime":
5, "statusPage": "https://rigetti.statuspage.io/"}]}, {"id": "qci", "currentAvailability":
"Degraded", "targets": [{"id": "qci.simulator", "currentAvailability": "Available",
"averageQueueTime": 1, "statusPage": "https://quantumcircuits.com"}, {"id":
"qci.machine1", "currentAvailability": "Unavailable", "averageQueueTime":
1, "statusPage": "https://quantumcircuits.com"}, {"id": "qci.simulator.noisy",
"currentAvailability": "Available", "averageQueueTime": 0, "statusPage": "https://quantumcircuits.com"}]},
{"id": "quantinuum", "currentAvailability": "Degraded", "targets": [{"id":
"quantinuum.qpu.h1-1", "currentAvailability": "Degraded", "averageQueueTime":
0, "statusPage": "https://www.quantinuum.com/hardware/h1"}, {"id": "quantinuum.sim.h1-1sc",
"currentAvailability": "Available", "averageQueueTime": 3, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.sim.h1-1e", "currentAvailability": "Available", "averageQueueTime":
7, "statusPage": "https://www.quantinuum.com/hardware/h1"}, {"id": "quantinuum.qpu.h2-1",
"currentAvailability": "Degraded", "averageQueueTime": 0, "statusPage": "https://www.quantinuum.com/hardware/h2"},
{"id": "quantinuum.sim.h2-1sc", "currentAvailability": "Available", "averageQueueTime":
0, "statusPage": "https://www.quantinuum.com/hardware/h2"}, {"id": "quantinuum.sim.h2-1e",
"currentAvailability": "Available", "averageQueueTime": 21291, "statusPage":
"https://www.quantinuum.com/hardware/h2"}, {"id": "quantinuum.sim.h1-1sc-preview",
"currentAvailability": "Available", "averageQueueTime": 3, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.sim.h1-1e-preview", "currentAvailability": "Available",
"averageQueueTime": 7, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.sim.h1-2e-preview", "currentAvailability": "Available",
"averageQueueTime": 0, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.qpu.h1-1-preview", "currentAvailability": "Degraded", "averageQueueTime":
0, "statusPage": "https://www.quantinuum.com/hardware/h1"}]}, {"id": "Microsoft.Test",
"currentAvailability": "Available", "targets": [{"id": "echo-rigetti", "currentAvailability":
"Available", "averageQueueTime": 1, "statusPage": ""}, {"id": "echo-quantinuum",
"currentAvailability": "Available", "averageQueueTime": 1, "statusPage": ""},
{"id": "echo-qci", "currentAvailability": "Available", "averageQueueTime":
1, "statusPage": ""}, {"id": "echo-ionq", "currentAvailability": "Available",
"averageQueueTime": 1, "statusPage": ""}, {"id": "echo-aquarius", "currentAvailability":
"Available", "averageQueueTime": 1, "statusPage": ""}, {"id": "sparse-sim-rigetti",
"currentAvailability": "Available", "averageQueueTime": 1, "statusPage": ""},
{"id": "sparse-sim-quantinuum", "currentAvailability": "Available", "averageQueueTime":
1, "statusPage": ""}, {"id": "sparse-sim-qci", "currentAvailability": "Available",
"averageQueueTime": 1, "statusPage": ""}, {"id": "sparse-sim-ionq", "currentAvailability":
"Available", "averageQueueTime": 1, "statusPage": ""}, {"id": "echo-output",
"currentAvailability": "Available", "averageQueueTime": 1, "statusPage": ""}]}],
"nextLink": null}'
headers:
connection:
- keep-alive
content-length:
- '4754'
content-type:
- application/json; charset=utf-8
transfer-encoding:
- chunked
status:
code: 200
message: OK
version: 1
Loading

0 comments on commit 0699fa5

Please sign in to comment.