Skip to content

Commit

Permalink
Replace some deprecated qiskit functions (#576)
Browse files Browse the repository at this point in the history
* Replace some depracated qiskit fuctions
  • Loading branch information
ArthurKamalov authored Feb 27, 2024
1 parent db9bc9d commit 8b8569b
Show file tree
Hide file tree
Showing 110 changed files with 21,452 additions and 15,789 deletions.
3 changes: 2 additions & 1 deletion azure-quantum/azure/quantum/qiskit/backends/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def _get_input_params(self, options: Dict[str, Any], shots: int = None) -> Dict[
if self._can_send_shots_input_param():
options_shots = options.pop(self.__class__._SHOTS_PARAM_NAME, None)

final_shots = None
# First we check for the explicitly specified 'shots' parameter, then for a provider-specific
# field in options, then for a backend's default value.

Expand All @@ -142,7 +143,7 @@ def _get_input_params(self, options: Dict[str, Any], shots: int = None) -> Dict[

elif shots is not None:
final_shots = shots
else:
elif options_shots is not None:
warnings.warn(
f"Parameter '{self.__class__._SHOTS_PARAM_NAME}' is subject to change in future versions. "
"Please, use 'shots' parameter instead."
Expand Down
5 changes: 3 additions & 2 deletions azure-quantum/azure/quantum/qiskit/backends/quantinuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from qiskit.providers.models import BackendConfiguration
from qiskit.providers import Options
from qiskit.providers import Provider
from qiskit.qasm2 import dumps

import logging

Expand Down Expand Up @@ -243,7 +244,7 @@ def _azure_config(self) -> Dict[str, str]:

def _translate_input(self, circuit):
"""Translates the input values to the format expected by the AzureBackend."""
return circuit.qasm()
return dumps(circuit)

def estimate_cost(
self, circuit: QuantumCircuit, shots: int = None, count: int = None
Expand All @@ -267,7 +268,7 @@ def estimate_cost(
if shots is None:
raise ValueError("Missing input argument 'shots'.")

input_data = circuit.qasm()
input_data = dumps(circuit)
workspace = self.provider().get_workspace()
target = workspace.get_targets(self.name())
return target.estimate_cost(input_data, shots=shots)
Expand Down
2 changes: 1 addition & 1 deletion azure-quantum/requirements-qiskit.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
qiskit-ionq>=0.3.3,<1.0
qiskit-qir>=0.4,<0.5
qiskit-terra>=0.45,<0.46
qiskit-terra>=0.46,<0.47
Markdown>=3.4.1,<4.0
python-markdown-math>=0.8.0,<1.0

Large diffs are not rendered by default.

Large diffs are not rendered by default.

280 changes: 201 additions & 79 deletions azure-quantum/tests/unit/recordings/test_dft_failure_invalid_input.yaml

Large diffs are not rendered by default.

312 changes: 155 additions & 157 deletions azure-quantum/tests/unit/recordings/test_dft_success.yaml

Large diffs are not rendered by default.

283 changes: 68 additions & 215 deletions azure-quantum/tests/unit/recordings/test_estimator_batching_job.yaml

Large diffs are not rendered by default.

102 changes: 32 additions & 70 deletions azure-quantum/tests/unit/recordings/test_estimator_failing_job.yaml

Large diffs are not rendered by default.

154 changes: 39 additions & 115 deletions azure-quantum/tests/unit/recordings/test_estimator_non_batching_job.yaml

Large diffs are not rendered by default.

113 changes: 37 additions & 76 deletions azure-quantum/tests/unit/recordings/test_estimator_profiling_job.yaml

Large diffs are not rendered by default.

112 changes: 37 additions & 75 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.

284 changes: 237 additions & 47 deletions azure-quantum/tests/unit/recordings/test_job_submit_ionq.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

161 changes: 61 additions & 100 deletions azure-quantum/tests/unit/recordings/test_parametrized_quil.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interactions:
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)
- azsdk-python-identity/1.15.0 Python/3.9.18 (Windows-10-10.0.22631-SP0)
x-client-current-telemetry:
- 4|730,2|
x-client-os:
Expand Down Expand Up @@ -46,21 +46,21 @@ interactions:
Connection:
- keep-alive
User-Agent:
- testapp-azure-quantum-cirq azsdk-python-quantum/0.0.1 Python/3.9.18 (Windows-10-10.0.22621-SP0)
- testapp-azure-quantum-cirq azsdk-python-quantum/0.0.1 Python/3.9.18 (Windows-10-10.0.22631-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": "Available", "averageQueueTime":
381072, "statusPage": "https://status.ionq.co"}, {"id": "ionq.qpu.aria-1",
"currentAvailability": "Available", "averageQueueTime": 1467020, "statusPage":
"targets": [{"id": "ionq.qpu", "currentAvailability": "Unavailable", "averageQueueTime":
6374471, "statusPage": "https://status.ionq.co"}, {"id": "ionq.qpu.aria-1",
"currentAvailability": "Available", "averageQueueTime": 5662524, "statusPage":
"https://status.ionq.co"}, {"id": "ionq.qpu.aria-2", "currentAvailability":
"Unavailable", "averageQueueTime": 1591912, "statusPage": "https://status.ionq.co"},
"Available", "averageQueueTime": 8697847, "statusPage": "https://status.ionq.co"},
{"id": "ionq.simulator", "currentAvailability": "Available", "averageQueueTime":
31, "statusPage": "https://status.ionq.co"}]}, {"id": "microsoft-qc", "currentAvailability":
10, "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",
Expand All @@ -69,62 +69,61 @@ interactions:
0, "statusPage": "https://pasqal.com"}]}, {"id": "rigetti", "currentAvailability":
"Available", "targets": [{"id": "rigetti.sim.qvm", "currentAvailability":
"Available", "averageQueueTime": 5, "statusPage": "https://rigetti.statuspage.io/"},
{"id": "rigetti.qpu.aspen-m-3", "currentAvailability": "Available", "averageQueueTime":
5, "statusPage": "https://rigetti.statuspage.io/"}, {"id": "rigetti.qpu.ankaa-9q-1",
"currentAvailability": "Available", "averageQueueTime": 5, "statusPage": "https://rigetti.statuspage.io/"},
{"id": "rigetti.qpu.ankaa-2", "currentAvailability": "Available", "averageQueueTime":
5, "statusPage": "https://rigetti.statuspage.io/"}]}, {"id": "Microsoft.Test",
"currentAvailability": "Available", "targets": [{"id": "echo-rigetti", "currentAvailability":
"Available", "averageQueueTime": 1, "statusPage": ""}, {"id": "echo-quantinuum",
{"id": "rigetti.qpu.ankaa-9q-1", "currentAvailability": "Available", "averageQueueTime":
5, "statusPage": "https://rigetti.statuspage.io/"}, {"id": "rigetti.qpu.ankaa-2",
"currentAvailability": "Available", "averageQueueTime": 5, "statusPage": "https://rigetti.statuspage.io/"}]},
{"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-qci", "currentAvailability": "Available", "averageQueueTime":
1, "statusPage": ""}, {"id": "echo-ionq", "currentAvailability": "Available",
"averageQueueTime": 1, "statusPage": ""}, {"id": "sparse-sim-rigetti", "currentAvailability":
"Available", "averageQueueTime": 1, "statusPage": ""}, {"id": "sparse-sim-quantinuum",
{"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-qci", "currentAvailability": "Available", "averageQueueTime":
1, "statusPage": ""}, {"id": "sparse-sim-ionq", "currentAvailability": "Available",
"averageQueueTime": 1, "statusPage": ""}, {"id": "echo-output", "currentAvailability":
"Available", "averageQueueTime": 1, "statusPage": ""}]}, {"id": "qci", "currentAvailability":
{"id": "sparse-sim-ionq", "currentAvailability": "Available", "averageQueueTime":
1, "statusPage": ""}, {"id": "echo-output", "currentAvailability": "Available",
"averageQueueTime": 1, "statusPage": ""}]}, {"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": "Available", "averageQueueTime":
99720, "statusPage": "https://www.quantinuum.com/hardware/h1"}, {"id": "quantinuum.sim.h1-1sc",
"currentAvailability": "Available", "averageQueueTime": 0, "statusPage": "https://www.quantinuum.com/hardware/h1"},
"quantinuum.qpu.h1-1", "currentAvailability": "Unavailable", "averageQueueTime":
0, "statusPage": "https://www.quantinuum.com/hardware/h1"}, {"id": "quantinuum.sim.h1-1sc",
"currentAvailability": "Available", "averageQueueTime": 7, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.qpu.h1-2", "currentAvailability": "Unavailable", "averageQueueTime":
0, "statusPage": "https://www.quantinuum.com/hardware/h1"}, {"id": "quantinuum.sim.h1-2sc",
"currentAvailability": "Unavailable", "averageQueueTime": 0, "statusPage":
"https://www.quantinuum.com/hardware/h1"}, {"id": "quantinuum.sim.h1-1e",
"currentAvailability": "Available", "averageQueueTime": 4174, "statusPage":
"currentAvailability": "Available", "averageQueueTime": 151, "statusPage":
"https://www.quantinuum.com/hardware/h1"}, {"id": "quantinuum.sim.h1-2e",
"currentAvailability": "Unavailable", "averageQueueTime": 0, "statusPage":
"https://www.quantinuum.com/hardware/h1"}, {"id": "quantinuum.qpu.h2-1", "currentAvailability":
"Available", "averageQueueTime": 23280, "statusPage": "https://www.quantinuum.com/hardware/h2"},
"Degraded", "averageQueueTime": 0, "statusPage": "https://www.quantinuum.com/hardware/h2"},
{"id": "quantinuum.sim.h2-1sc", "currentAvailability": "Available", "averageQueueTime":
13, "statusPage": "https://www.quantinuum.com/hardware/h2"}, {"id": "quantinuum.sim.h2-1e",
"currentAvailability": "Available", "averageQueueTime": 949, "statusPage":
"https://www.quantinuum.com/hardware/h2"}, {"id": "quantinuum.sim.h1-1sc-preview",
"currentAvailability": "Available", "averageQueueTime": 0, "statusPage": "https://www.quantinuum.com/hardware/h1"},
6, "statusPage": "https://www.quantinuum.com/hardware/h2"}, {"id": "quantinuum.sim.h2-1e",
"currentAvailability": "Available", "averageQueueTime": 0, "statusPage": "https://www.quantinuum.com/hardware/h2"},
{"id": "quantinuum.sim.h1-1sc-preview", "currentAvailability": "Available",
"averageQueueTime": 7, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.sim.h1-2sc-preview", "currentAvailability": "Unavailable",
"averageQueueTime": 0, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.sim.h1-1e-preview", "currentAvailability": "Available",
"averageQueueTime": 4174, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.sim.h1-2e-preview", "currentAvailability": "Unavailable",
"averageQueueTime": 151, "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": "Unavailable",
"averageQueueTime": 0, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.qpu.h1-1-preview", "currentAvailability": "Available",
"averageQueueTime": 99720, "statusPage": "https://www.quantinuum.com/hardware/h1"},
{"id": "quantinuum.qpu.h1-2-preview", "currentAvailability": "Unavailable",
"averageQueueTime": 0, "statusPage": "https://www.quantinuum.com/hardware/h1"}]}],
"nextLink": null, "access_token": "fake_token"}'
headers:
connection:
- keep-alive
content-length:
- '5752'
- '5597'
content-type:
- application/json; charset=utf-8
transfer-encoding:
Expand Down
Loading

0 comments on commit 8b8569b

Please sign in to comment.