azure-quantum 1.0.0.dev1__py3-none-any.whl → 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- azure/quantum/__init__.py +6 -0
- azure/quantum/_client/_version.py +1 -1
- azure/quantum/argument_types/__init__.py +3 -0
- azure/quantum/argument_types/types.py +19 -0
- azure/quantum/cirq/__init__.py +6 -0
- azure/quantum/cirq/job.py +9 -1
- azure/quantum/cirq/service.py +25 -12
- azure/quantum/cirq/targets/__init__.py +2 -0
- azure/quantum/job/__init__.py +22 -5
- azure/quantum/job/base_job.py +25 -17
- azure/quantum/job/filtered_job.py +6 -0
- azure/quantum/job/job.py +4 -4
- azure/quantum/job/session.py +17 -7
- azure/quantum/job/workspace_item.py +7 -2
- azure/quantum/qiskit/backends/__init__.py +2 -0
- azure/quantum/qiskit/backends/backend.py +9 -5
- azure/quantum/qiskit/backends/quantinuum.py +1 -1
- azure/quantum/qiskit/provider.py +13 -10
- azure/quantum/target/__init__.py +11 -5
- azure/quantum/target/ionq.py +3 -3
- azure/quantum/target/microsoft/__init__.py +3 -0
- azure/quantum/target/microsoft/elements/__init__.py +1 -0
- azure/quantum/target/microsoft/elements/dft/__init__.py +2 -0
- azure/quantum/target/microsoft/elements/dft/job.py +17 -0
- azure/quantum/target/microsoft/elements/dft/target.py +21 -0
- azure/quantum/target/microsoft/job.py +8 -0
- azure/quantum/target/microsoft/target.py +19 -1
- azure/quantum/target/params.py +3 -0
- azure/quantum/target/pasqal/result.py +11 -5
- azure/quantum/target/pasqal/target.py +2 -0
- azure/quantum/target/quantinuum.py +9 -10
- azure/quantum/target/rigetti/result.py +2 -0
- azure/quantum/target/rigetti/target.py +4 -5
- azure/quantum/target/target.py +38 -3
- azure/quantum/target/target_factory.py +2 -8
- azure/quantum/version.py +1 -1
- azure/quantum/workspace.py +40 -15
- {azure_quantum-1.0.0.dev1.dist-info → azure_quantum-1.1.0.dist-info}/METADATA +16 -17
- azure_quantum-1.1.0.dist-info/RECORD +76 -0
- azure/quantum/optimization/__init__.py +0 -11
- azure/quantum/optimization/online_problem.py +0 -21
- azure/quantum/optimization/problem.py +0 -393
- azure/quantum/optimization/solvers.py +0 -10
- azure/quantum/optimization/streaming_problem.py +0 -387
- azure/quantum/optimization/term.py +0 -203
- azure/quantum/optimization/toshiba/__init__.py +0 -10
- azure/quantum/optimization/toshiba/solvers.py +0 -12
- azure/quantum/target/solvers.py +0 -382
- azure/quantum/target/toshiba/__init__.py +0 -7
- azure/quantum/target/toshiba/solvers.py +0 -130
- azure_quantum-1.0.0.dev1.dist-info/RECORD +0 -86
- {azure_quantum-1.0.0.dev1.dist-info → azure_quantum-1.1.0.dist-info}/WHEEL +0 -0
- {azure_quantum-1.0.0.dev1.dist-info → azure_quantum-1.1.0.dist-info}/top_level.txt +0 -0
azure/quantum/qiskit/provider.py
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
# Licensed under the MIT License.
|
|
4
4
|
##
|
|
5
5
|
|
|
6
|
+
import warnings
|
|
7
|
+
import inspect
|
|
8
|
+
from itertools import groupby
|
|
9
|
+
from typing import Dict, List, Tuple, Type
|
|
10
|
+
from azure.quantum import Workspace
|
|
11
|
+
|
|
6
12
|
try:
|
|
7
13
|
from qiskit.providers import ProviderV1 as Provider
|
|
8
14
|
from qiskit.providers.exceptions import QiskitBackendNotFoundError
|
|
@@ -14,18 +20,10 @@ except ImportError:
|
|
|
14
20
|
To install run: pip install azure-quantum[qiskit]"
|
|
15
21
|
)
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
from typing import Dict, List, Tuple, Type
|
|
19
|
-
from azure.quantum import Workspace
|
|
20
23
|
from azure.quantum.qiskit.backends.backend import AzureBackendBase
|
|
21
24
|
from azure.quantum.qiskit.job import AzureQuantumJob
|
|
22
25
|
from azure.quantum.qiskit.backends import *
|
|
23
|
-
from itertools import groupby
|
|
24
|
-
import warnings
|
|
25
|
-
import inspect
|
|
26
26
|
|
|
27
|
-
# Target ID keyword for parameter-free solvers
|
|
28
|
-
PARAMETER_FREE = "parameterfree"
|
|
29
27
|
|
|
30
28
|
QISKIT_USER_AGENT = "azure-quantum-qiskit"
|
|
31
29
|
|
|
@@ -39,7 +37,7 @@ class AzureQuantumProvider(Provider):
|
|
|
39
37
|
"""AzureQuantumService class
|
|
40
38
|
|
|
41
39
|
:param workspace: Azure Quantum workspace. If missing it will create a new Workspace passing `kwargs` to the constructor. Defaults to None.
|
|
42
|
-
:type workspace: Workspace
|
|
40
|
+
:type workspace: Workspace
|
|
43
41
|
"""
|
|
44
42
|
if kwargs is not None and len(kwargs) > 0:
|
|
45
43
|
from warnings import warn
|
|
@@ -57,10 +55,13 @@ class AzureQuantumProvider(Provider):
|
|
|
57
55
|
self._backends = None
|
|
58
56
|
|
|
59
57
|
def get_workspace(self) -> Workspace:
|
|
58
|
+
"""Return Azure Quantum Workspace"""
|
|
59
|
+
|
|
60
60
|
return self._workspace
|
|
61
61
|
|
|
62
62
|
def get_backend(self, name=None, **kwargs) -> AzureBackendBase:
|
|
63
63
|
"""Return a single backend matching the specified filtering.
|
|
64
|
+
|
|
64
65
|
Args:
|
|
65
66
|
name (str): name of the backend.
|
|
66
67
|
**kwargs: dict used for filtering.
|
|
@@ -104,11 +105,12 @@ see https://aka.ms/AQ/Docs/AddProvider"
|
|
|
104
105
|
|
|
105
106
|
def backends(self, name=None, **kwargs):
|
|
106
107
|
"""Return a list of backends matching the specified filtering.
|
|
108
|
+
|
|
107
109
|
Args:
|
|
108
110
|
name (str): name of the backend.
|
|
109
111
|
**kwargs: dict used for filtering.
|
|
110
112
|
Returns:
|
|
111
|
-
|
|
113
|
+
typing.List[qiskit.providers.BackendV1]: a list of Backends that match the filtering
|
|
112
114
|
criteria.
|
|
113
115
|
"""
|
|
114
116
|
|
|
@@ -237,6 +239,7 @@ see https://aka.ms/AQ/Docs/AddProvider"
|
|
|
237
239
|
or from a boolean callable. The criteria for filtering can
|
|
238
240
|
be specified via `**kwargs` or as a callable via `filters`, and the
|
|
239
241
|
backends must fulfill all specified conditions.
|
|
242
|
+
|
|
240
243
|
Args:
|
|
241
244
|
backends (list[Backend]): list of backends.
|
|
242
245
|
filters (callable): filtering conditions as a callable.
|
azure/quantum/target/__init__.py
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
# Copyright (c) Microsoft Corporation.
|
|
3
3
|
# Licensed under the MIT License.
|
|
4
4
|
##
|
|
5
|
+
|
|
6
|
+
"""Defines set of targets for interacting with Azure Quantum"""
|
|
7
|
+
|
|
5
8
|
from .target import Target
|
|
6
|
-
from .solvers import Solver
|
|
7
|
-
from .toshiba import (
|
|
8
|
-
SimulatedBifurcationMachine
|
|
9
|
-
)
|
|
10
9
|
from .ionq import IonQ
|
|
11
10
|
from .quantinuum import Quantinuum
|
|
12
11
|
from .rigetti import Rigetti
|
|
@@ -19,6 +18,13 @@ DEFAULT_TARGETS = {
|
|
|
19
18
|
"ionq": IonQ,
|
|
20
19
|
"quantinuum": Quantinuum,
|
|
21
20
|
"rigetti": Rigetti,
|
|
22
|
-
"toshiba": Solver,
|
|
23
21
|
"pasqal": Pasqal
|
|
24
22
|
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"Target",
|
|
27
|
+
"IonQ",
|
|
28
|
+
"Quantinuum",
|
|
29
|
+
"DEFAULT_TARGETS"
|
|
30
|
+
]
|
azure/quantum/target/ionq.py
CHANGED
|
@@ -162,12 +162,12 @@ class IonQ(Target):
|
|
|
162
162
|
:type num_shots: int
|
|
163
163
|
:param price_1q: The price of running a single-qubit gate
|
|
164
164
|
for one shot.
|
|
165
|
-
:type price_1q: float
|
|
165
|
+
:type price_1q: float
|
|
166
166
|
:param price_2q: The price of running a double-qubit gate
|
|
167
167
|
for one shot.
|
|
168
|
-
:type price_2q: float
|
|
168
|
+
:type price_2q: float
|
|
169
169
|
:param min_price: The minimum price for running a job.
|
|
170
|
-
:type min_price: float
|
|
170
|
+
:type min_price: float
|
|
171
171
|
:param shots: Number of shots, defaults to None
|
|
172
172
|
:type shots: int
|
|
173
173
|
"""
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
# Licensed under the MIT License.
|
|
4
4
|
##
|
|
5
|
+
|
|
6
|
+
"""Defines classes for interacting with Microsoft Estimator"""
|
|
7
|
+
|
|
5
8
|
__all__ = ["ErrorBudgetPartition", "MicrosoftEstimator",
|
|
6
9
|
"MicrosoftEstimatorJob", "MicrosoftEstimatorResult",
|
|
7
10
|
"MicrosoftEstimatorParams", "QECScheme", "QubitParams"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Defines classes for interacting with Microsoft Elements services"""
|
|
@@ -10,10 +10,27 @@ class MicrosoftElementsDftJob(Job):
|
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
def __init__(self, workspace, job_details: JobDetails, **kwargs):
|
|
13
|
+
"""Azure Quantum Job that is submitted to a given Workspace.
|
|
14
|
+
|
|
15
|
+
:param workspace: Workspace instance to submit job to
|
|
16
|
+
:type workspace: Workspace
|
|
17
|
+
:param job_details: Job details model,
|
|
18
|
+
contains Job ID, name and other details
|
|
19
|
+
:type job_details: JobDetails
|
|
20
|
+
"""
|
|
13
21
|
super().__init__(workspace, job_details, **kwargs)
|
|
14
22
|
|
|
15
23
|
|
|
16
24
|
def get_results(self, timeout_secs: float = DEFAULT_TIMEOUT) -> Dict[str, Any]:
|
|
25
|
+
"""Get job results by downloading the results blob from the
|
|
26
|
+
storage container linked via the workspace.
|
|
27
|
+
|
|
28
|
+
:param timeout_secs: Timeout in seconds, defaults to 300
|
|
29
|
+
:type timeout_secs: float
|
|
30
|
+
:raises RuntimeError: Raises RuntimeError if job execution failed
|
|
31
|
+
:return: Results dictionary with histogram shots, or raw results if not a json object.
|
|
32
|
+
"""
|
|
33
|
+
|
|
17
34
|
try:
|
|
18
35
|
job_results = super().get_results(timeout_secs)
|
|
19
36
|
return job_results["results"]
|
|
@@ -25,6 +25,13 @@ class MicrosoftElementsDft(Target):
|
|
|
25
25
|
name: str = "microsoft.dft",
|
|
26
26
|
**kwargs
|
|
27
27
|
):
|
|
28
|
+
"""
|
|
29
|
+
Initializes a new DFT target.
|
|
30
|
+
|
|
31
|
+
:param workspace: Associated workspace
|
|
32
|
+
:type workspace: Workspace
|
|
33
|
+
:param name: Target name
|
|
34
|
+
"""
|
|
28
35
|
# There is only a single target name for this target
|
|
29
36
|
assert name == self.target_names[0]
|
|
30
37
|
|
|
@@ -48,6 +55,20 @@ class MicrosoftElementsDft(Target):
|
|
|
48
55
|
shots: int = None,
|
|
49
56
|
input_params: Union[Dict[str, Any], InputParams, None] = None,
|
|
50
57
|
**kwargs) -> MicrosoftElementsDftJob:
|
|
58
|
+
"""
|
|
59
|
+
Submit DFT job to Azure Quantum Services.
|
|
60
|
+
|
|
61
|
+
:param input_data: Input data
|
|
62
|
+
:type input_data: Any
|
|
63
|
+
:param name: Job name
|
|
64
|
+
:type name: str
|
|
65
|
+
:param shots: Number of shots. Ignored in DFT job. Defaults to None
|
|
66
|
+
:type shots: int
|
|
67
|
+
:param input_params: Input parameters
|
|
68
|
+
:type input_params: Dict[str, Any]
|
|
69
|
+
:return: Azure Quantum job
|
|
70
|
+
:rtype: Job
|
|
71
|
+
"""
|
|
51
72
|
|
|
52
73
|
if shots is not None:
|
|
53
74
|
warnings.warn("The 'shots' parameter is ignored in Microsoft Elements Dft job.")
|
|
@@ -16,6 +16,14 @@ class MicrosoftEstimatorJob(Job):
|
|
|
16
16
|
super().__init__(workspace, job_details, **kwargs)
|
|
17
17
|
|
|
18
18
|
def get_results(self, timeout_secs: float = DEFAULT_TIMEOUT) -> MicrosoftEstimatorResult:
|
|
19
|
+
"""
|
|
20
|
+
Get estimation result.
|
|
21
|
+
|
|
22
|
+
:param timeout_secs: Timeout in seconds, defaults to 300 sec.
|
|
23
|
+
:type timeout_secs: float
|
|
24
|
+
:return: Estimation result
|
|
25
|
+
:rtype: MicrosoftEstimatorResult
|
|
26
|
+
"""
|
|
19
27
|
try:
|
|
20
28
|
results = super().get_results(timeout_secs)
|
|
21
29
|
return MicrosoftEstimatorResult(results)
|
|
@@ -16,6 +16,10 @@ from ..target import Target
|
|
|
16
16
|
from . import MicrosoftEstimatorJob
|
|
17
17
|
|
|
18
18
|
class QubitParams:
|
|
19
|
+
"""
|
|
20
|
+
Resource estimator Qubit parameters.
|
|
21
|
+
"""
|
|
22
|
+
|
|
19
23
|
GATE_US_E3 = "qubit_gate_us_e3"
|
|
20
24
|
GATE_US_E4 = "qubit_gate_us_e4"
|
|
21
25
|
GATE_NS_E3 = "qubit_gate_ns_e3"
|
|
@@ -25,6 +29,10 @@ class QubitParams:
|
|
|
25
29
|
|
|
26
30
|
|
|
27
31
|
class QECScheme:
|
|
32
|
+
"""
|
|
33
|
+
Resource estimator QEC Scheme.
|
|
34
|
+
"""
|
|
35
|
+
|
|
28
36
|
SURFACE_CODE = "surface_code"
|
|
29
37
|
FLOQUET_CODE = "floquet_code"
|
|
30
38
|
|
|
@@ -243,6 +251,9 @@ class DistillationUnitSpecification(AutoValidatingParams):
|
|
|
243
251
|
|
|
244
252
|
@dataclass
|
|
245
253
|
class ErrorBudgetPartition(AutoValidatingParams):
|
|
254
|
+
"""
|
|
255
|
+
Resource estimator error budget partition parameters.
|
|
256
|
+
"""
|
|
246
257
|
logical: float = 0.001 / 3
|
|
247
258
|
t_states: float = 0.001 / 3
|
|
248
259
|
rotations: float = 0.001 / 3
|
|
@@ -250,6 +261,10 @@ class ErrorBudgetPartition(AutoValidatingParams):
|
|
|
250
261
|
|
|
251
262
|
@dataclass
|
|
252
263
|
class MicrosoftEstimatorConstraints(AutoValidatingParams):
|
|
264
|
+
"""
|
|
265
|
+
Resource estimator constraints.
|
|
266
|
+
"""
|
|
267
|
+
|
|
253
268
|
@staticmethod
|
|
254
269
|
def at_least_one(name, value):
|
|
255
270
|
if value < 1:
|
|
@@ -339,6 +354,9 @@ class MicrosoftEstimatorInputParamsItem(InputParamsItem):
|
|
|
339
354
|
|
|
340
355
|
|
|
341
356
|
class MicrosoftEstimatorParams(InputParams, MicrosoftEstimatorInputParamsItem):
|
|
357
|
+
"""
|
|
358
|
+
Resource estimator input parameters.
|
|
359
|
+
"""
|
|
342
360
|
def __init__(self, num_items: Optional[int] = None):
|
|
343
361
|
InputParams.__init__(
|
|
344
362
|
self,
|
|
@@ -386,7 +404,7 @@ class MicrosoftEstimator(Target):
|
|
|
386
404
|
**kwargs,
|
|
387
405
|
) -> Job:
|
|
388
406
|
"""
|
|
389
|
-
Submit an estimation job
|
|
407
|
+
Submit an estimation job.
|
|
390
408
|
|
|
391
409
|
:param input_data: Input data
|
|
392
410
|
:type input_data: Any
|
azure/quantum/target/params.py
CHANGED
|
@@ -18,17 +18,23 @@ from ...job import Job
|
|
|
18
18
|
class Result:
|
|
19
19
|
"""Downloads the data of a completed Job and provides a dictionary of registers.
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
.. highlight:: python
|
|
22
|
+
.. code-block::
|
|
23
|
+
|
|
24
|
+
from azure.quantum.job import Job
|
|
25
|
+
from azure.quantum.target.pasqal import Result
|
|
26
|
+
job = Job(...) # This job should come from a Pasqal target
|
|
27
|
+
job.wait_until_completed()
|
|
28
|
+
result = Result(job)
|
|
29
|
+
|
|
26
30
|
"""
|
|
27
31
|
|
|
28
32
|
def __init__(self, job: Job) -> None:
|
|
29
33
|
"""
|
|
30
34
|
Decode the results of a Job with output type of "pasqal.pulser-results.v1"
|
|
31
35
|
|
|
36
|
+
:param job: Azure Quantum job
|
|
37
|
+
:type job: Job
|
|
32
38
|
:raises: RuntimeError if the job has not completed successfully
|
|
33
39
|
"""
|
|
34
40
|
|
|
@@ -121,18 +121,18 @@ class Quantinuum(Target):
|
|
|
121
121
|
:param circuit: Quantum circuit in OpenQASM 2.0 format
|
|
122
122
|
:type circuit: str
|
|
123
123
|
:param num_shots: Number of shots for which to estimate costs
|
|
124
|
-
:type num_shots: int
|
|
124
|
+
:type num_shots: int
|
|
125
125
|
:param N_1q: Number of one-qubit gates, if not specified,
|
|
126
126
|
this is estimated from the circuit
|
|
127
|
-
:type N_1q: int
|
|
127
|
+
:type N_1q: int
|
|
128
128
|
:param N_2q: Number of two-qubit gates, if not specified,
|
|
129
129
|
this is estimated from the circuit
|
|
130
|
-
:type N_2q: int
|
|
130
|
+
:type N_2q: int
|
|
131
131
|
:param N_m: Number of measurement operations, if not specified,
|
|
132
132
|
this is estimated from the circuit
|
|
133
|
-
:type N_m: int
|
|
133
|
+
:type N_m: int
|
|
134
134
|
:param shots: Number of shots for which to estimate costs
|
|
135
|
-
:type shots: int
|
|
135
|
+
:type shots: int
|
|
136
136
|
:raises ImportError: If N_1q, N_2q and N_m are not specified,
|
|
137
137
|
this will require a qiskit installation.
|
|
138
138
|
"""
|
|
@@ -149,8 +149,8 @@ class Quantinuum(Target):
|
|
|
149
149
|
|
|
150
150
|
if circuit is not None and (N_1q is None or N_2q is None or N_m is None):
|
|
151
151
|
try:
|
|
152
|
-
from qiskit.
|
|
153
|
-
from qiskit.converters import
|
|
152
|
+
from qiskit.qasm2 import loads
|
|
153
|
+
from qiskit.converters.circuit_to_dag import circuit_to_dag
|
|
154
154
|
|
|
155
155
|
except ImportError:
|
|
156
156
|
raise ImportError(
|
|
@@ -160,9 +160,8 @@ class Quantinuum(Target):
|
|
|
160
160
|
|
|
161
161
|
else:
|
|
162
162
|
from qiskit.dagcircuit.dagnode import DAGOpNode
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
dag = ast_to_dag(ast)
|
|
163
|
+
circuit_obj = loads(string=circuit)
|
|
164
|
+
dag = circuit_to_dag(circuit=circuit_obj)
|
|
166
165
|
N_1q, N_2q, N_m = 0, 0, 0
|
|
167
166
|
for node in dag._multi_graph.nodes():
|
|
168
167
|
if isinstance(node, DAGOpNode):
|
|
@@ -30,7 +30,6 @@ class RigettiTarget(str, Enum):
|
|
|
30
30
|
"""A simulator target for Quil. See https://github.com/quil-lang/qvm for more info."""
|
|
31
31
|
|
|
32
32
|
ANKAA_9Q_1 = "rigetti.qpu.ankaa-9q-1"
|
|
33
|
-
ASPEN_M_3 = "rigetti.qpu.aspen-m-3"
|
|
34
33
|
ANKAA_2 = "rigetti.qpu.ankaa-2"
|
|
35
34
|
|
|
36
35
|
def simulators() -> List[str]:
|
|
@@ -43,7 +42,6 @@ class RigettiTarget(str, Enum):
|
|
|
43
42
|
"""Returns a list of QPU targets"""
|
|
44
43
|
return [
|
|
45
44
|
RigettiTarget.ANKAA_9Q_1.value,
|
|
46
|
-
RigettiTarget.ASPEN_M_3.value,
|
|
47
45
|
RigettiTarget.ANKAA_2.value,
|
|
48
46
|
]
|
|
49
47
|
|
|
@@ -54,8 +52,6 @@ class RigettiTarget(str, Enum):
|
|
|
54
52
|
return 9
|
|
55
53
|
elif target_name == RigettiTarget.QVM.value:
|
|
56
54
|
return 20
|
|
57
|
-
elif target_name == RigettiTarget.ASPEN_M_3.value:
|
|
58
|
-
return 80
|
|
59
55
|
elif target_name == RigettiTarget.ANKAA_2.value:
|
|
60
56
|
return 84
|
|
61
57
|
else:
|
|
@@ -71,9 +67,12 @@ class InputParams:
|
|
|
71
67
|
"""
|
|
72
68
|
|
|
73
69
|
skip_quilc: bool = False
|
|
74
|
-
"""
|
|
70
|
+
"""
|
|
71
|
+
If set to True, `quilc`_ will not be run.
|
|
75
72
|
|
|
76
73
|
This **must** be set true if using `Quil-T <https://pyquil-docs.rigetti.com/en/stable/quilt.html>`_.
|
|
74
|
+
|
|
75
|
+
.. _quilc: https://github.com/quil-lang/quilc
|
|
77
76
|
"""
|
|
78
77
|
|
|
79
78
|
substitutions: Optional[Dict[str, List[List[float]]]] = None
|
azure/quantum/target/target.py
CHANGED
|
@@ -42,6 +42,7 @@ class Target(abc.ABC, SessionHost):
|
|
|
42
42
|
# __init__ via the job_cls parameter. This is then used by the target's
|
|
43
43
|
# submit and get_job method.
|
|
44
44
|
target_names = ()
|
|
45
|
+
"""Tuple of target names."""
|
|
45
46
|
|
|
46
47
|
# Name of the provider's input parameter which specifies number of shots for a submitted job.
|
|
47
48
|
# If None, target will not pass this input parameter.
|
|
@@ -62,6 +63,27 @@ class Target(abc.ABC, SessionHost):
|
|
|
62
63
|
):
|
|
63
64
|
"""
|
|
64
65
|
Initializes a new target.
|
|
66
|
+
|
|
67
|
+
:param workspace: Associated workspace
|
|
68
|
+
:type workspace: Workspace
|
|
69
|
+
:param name: Target name
|
|
70
|
+
:type name: str
|
|
71
|
+
:param input_data_format: Format of input data (ex. "qir.v1")
|
|
72
|
+
:type input_data_format: str
|
|
73
|
+
:param output_data_format: Format of output data (ex. "microsoft.resource-estimates.v1")
|
|
74
|
+
:type output_data_format: str
|
|
75
|
+
:param capability: QIR capability
|
|
76
|
+
:type capability: str
|
|
77
|
+
:param provider_id: Id of provider (ex. "microsoft-qc")
|
|
78
|
+
:type provider_id: str
|
|
79
|
+
:param content_type: "Content-Type" attribute value to set on input blob (ex. "application/json")
|
|
80
|
+
:type content_type: ContentType
|
|
81
|
+
:param encoding: "Content-Encoding" attribute value to set on input blob (ex. "gzip")
|
|
82
|
+
:type encoding: str
|
|
83
|
+
:param average_queue_time: Set average queue time (for internal use)
|
|
84
|
+
:type average_queue_time: float
|
|
85
|
+
:param current_availability: Set current availability (for internal use)
|
|
86
|
+
:type current_availability: str
|
|
65
87
|
"""
|
|
66
88
|
if not provider_id and "." in name:
|
|
67
89
|
provider_id = name.split(".")[0]
|
|
@@ -132,10 +154,18 @@ target '{self.name}' of provider '{self.provider_id}' not found."
|
|
|
132
154
|
|
|
133
155
|
@property
|
|
134
156
|
def current_availability(self):
|
|
157
|
+
"""
|
|
158
|
+
Current availability.
|
|
159
|
+
"""
|
|
160
|
+
|
|
135
161
|
return self._current_availability
|
|
136
162
|
|
|
137
163
|
@property
|
|
138
164
|
def average_queue_time(self):
|
|
165
|
+
"""
|
|
166
|
+
Average queue time.
|
|
167
|
+
"""
|
|
168
|
+
|
|
139
169
|
return self._average_queue_time
|
|
140
170
|
|
|
141
171
|
@staticmethod
|
|
@@ -183,7 +213,7 @@ target '{self.name}' of provider '{self.provider_id}' not found."
|
|
|
183
213
|
:param input_params: Input parameters
|
|
184
214
|
:type input_params: Dict[str, Any]
|
|
185
215
|
:return: Azure Quantum job
|
|
186
|
-
:rtype: Job
|
|
216
|
+
:rtype: azure.quantum.job.Job
|
|
187
217
|
"""
|
|
188
218
|
|
|
189
219
|
if isinstance(input_params, InputParams):
|
|
@@ -240,13 +270,15 @@ target '{self.name}' of provider '{self.provider_id}' not found."
|
|
|
240
270
|
# The 'shots' parameter has highest priority.
|
|
241
271
|
elif shots is not None:
|
|
242
272
|
final_shots = shots
|
|
243
|
-
# if
|
|
244
|
-
|
|
273
|
+
# if 'shots' parameter is not specified, try a provider-specific option.
|
|
274
|
+
elif input_params_shots is not None:
|
|
245
275
|
warnings.warn(
|
|
246
276
|
f"Field '{self.__class__._SHOTS_PARAM_NAME}' from the 'input_params' parameter is subject to change in future versions. "
|
|
247
277
|
"Please, use 'shots' parameter instead."
|
|
248
278
|
)
|
|
249
279
|
final_shots = input_params_shots
|
|
280
|
+
else:
|
|
281
|
+
final_shots = None
|
|
250
282
|
|
|
251
283
|
if final_shots is not None:
|
|
252
284
|
input_params[self.__class__._SHOTS_PARAM_NAME] = final_shots
|
|
@@ -281,6 +313,9 @@ target '{self.name}' of provider '{self.provider_id}' not found."
|
|
|
281
313
|
input_data: Any,
|
|
282
314
|
input_params: Union[Dict[str, Any], None] = None
|
|
283
315
|
):
|
|
316
|
+
"""
|
|
317
|
+
Estimate the cost for a given circuit.
|
|
318
|
+
"""
|
|
284
319
|
return NotImplementedError("Price estimation is not implemented yet for this target.")
|
|
285
320
|
|
|
286
321
|
def _get_azure_workspace(self) -> "Workspace":
|
|
@@ -10,9 +10,6 @@ if TYPE_CHECKING:
|
|
|
10
10
|
from azure.quantum import Workspace
|
|
11
11
|
from azure.quantum._client.models import TargetStatus
|
|
12
12
|
|
|
13
|
-
# Target ID keyword for parameter-free solvers
|
|
14
|
-
PARAMETER_FREE = "parameterfree"
|
|
15
|
-
|
|
16
13
|
|
|
17
14
|
class TargetFactory:
|
|
18
15
|
"""Factory class for generating a Target based on a
|
|
@@ -136,13 +133,10 @@ https://github.com/microsoft/qdk-python/issues.")
|
|
|
136
133
|
return self.from_target_status(*target_statuses[0], **kwargs)
|
|
137
134
|
|
|
138
135
|
else:
|
|
139
|
-
# Don't return redundant
|
|
136
|
+
# Don't return redundant targets
|
|
140
137
|
return [
|
|
141
138
|
self.from_target_status(_provider_id, status, **kwargs)
|
|
142
139
|
for _provider_id, status in target_statuses
|
|
143
|
-
if
|
|
144
|
-
and (
|
|
145
|
-
_provider_id.lower() in self._default_targets
|
|
140
|
+
if _provider_id.lower() in self._default_targets
|
|
146
141
|
or status.id in self._all_targets
|
|
147
|
-
)
|
|
148
142
|
]
|
azure/quantum/version.py
CHANGED