qcs-sdk-python-grpc-web 0.17.4__cp39-none-win_amd64.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.
- qcs_sdk/__init__.py +8 -0
- qcs_sdk/__init__.pyi +427 -0
- qcs_sdk/client.py +1 -0
- qcs_sdk/client.pyi +126 -0
- qcs_sdk/compiler/__init__.py +4 -0
- qcs_sdk/compiler/__init__.pyi +8 -0
- qcs_sdk/compiler/quilc.pyi +380 -0
- qcs_sdk/diagnostics.py +21 -0
- qcs_sdk/py.typed +0 -0
- qcs_sdk/qcs_sdk.cp39-win_amd64.pyd +0 -0
- qcs_sdk/qpu/__init__.py +4 -0
- qcs_sdk/qpu/__init__.pyi +207 -0
- qcs_sdk/qpu/api.pyi +443 -0
- qcs_sdk/qpu/isa.pyi +326 -0
- qcs_sdk/qpu/rewrite_arithmetic.pyi +65 -0
- qcs_sdk/qpu/translation.pyi +157 -0
- qcs_sdk/qvm/__init__.py +4 -0
- qcs_sdk/qvm/__init__.pyi +152 -0
- qcs_sdk/qvm/api.pyi +292 -0
- qcs_sdk_python_grpc_web-0.17.4.dist-info/METADATA +95 -0
- qcs_sdk_python_grpc_web-0.17.4.dist-info/RECORD +22 -0
- qcs_sdk_python_grpc_web-0.17.4.dist-info/WHEEL +4 -0
qcs_sdk/__init__.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# type: ignore
|
|
2
|
+
# See the following documentation for why this file is necessary:
|
|
3
|
+
# https://pyo3.rs/v0.18.0/python_typing_hints#__init__py-content
|
|
4
|
+
|
|
5
|
+
from .qcs_sdk import *
|
|
6
|
+
|
|
7
|
+
__doc__ = qcs_sdk.__doc__
|
|
8
|
+
__all__ = getattr(qcs_sdk, "__all__", []) + ["diagnostics"]
|
qcs_sdk/__init__.pyi
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The `qcs_sdk` package provides a Python interface to the Rigetti Quantum Cloud Services (QCS) platform.
|
|
3
|
+
|
|
4
|
+
For more information about QCS, see [the QCS documentation](https://docs.rigetti.com/qcs/).
|
|
5
|
+
|
|
6
|
+
⚠️ This package is still in early development and breaking changes should be expected between minor versions.
|
|
7
|
+
"""
|
|
8
|
+
import datetime
|
|
9
|
+
from enum import Enum
|
|
10
|
+
from typing import Dict, Iterable, List, Optional, Sequence, Tuple, Union, final
|
|
11
|
+
|
|
12
|
+
import numpy as np
|
|
13
|
+
from numpy.typing import NDArray
|
|
14
|
+
|
|
15
|
+
from qcs_sdk.client import QCSClient as QCSClient
|
|
16
|
+
from qcs_sdk.compiler.quilc import CompilerOpts, QuilcClient
|
|
17
|
+
from qcs_sdk.qpu import QPUResultData, RawQPUReadoutData
|
|
18
|
+
from qcs_sdk.qpu.api import ExecutionOptions
|
|
19
|
+
from qcs_sdk.qpu.translation import TranslationOptions
|
|
20
|
+
from qcs_sdk.qvm import QVMClient, QVMResultData, RawQVMReadoutData
|
|
21
|
+
|
|
22
|
+
from qcs_sdk import client as client
|
|
23
|
+
from qcs_sdk import compiler as compiler
|
|
24
|
+
from qcs_sdk import qpu as qpu
|
|
25
|
+
from qcs_sdk import qvm as qvm
|
|
26
|
+
|
|
27
|
+
class ExecutionError(RuntimeError):
|
|
28
|
+
"""Error encountered when executing a program."""
|
|
29
|
+
|
|
30
|
+
...
|
|
31
|
+
|
|
32
|
+
@final
|
|
33
|
+
class Executable:
|
|
34
|
+
"""
|
|
35
|
+
The builder interface for executing Quil programs on QVMs and QPUs.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
def __new__(
|
|
39
|
+
cls,
|
|
40
|
+
quil: str,
|
|
41
|
+
/,
|
|
42
|
+
registers: Optional[Sequence[str]] = None,
|
|
43
|
+
parameters: Optional[Sequence[ExeParameter]] = None,
|
|
44
|
+
shots: Optional[int] = None,
|
|
45
|
+
quilc_client: Optional[QuilcClient] = None,
|
|
46
|
+
compiler_options: Optional[CompilerOpts] = None,
|
|
47
|
+
) -> "Executable": ...
|
|
48
|
+
def execute_on_qvm(self, client: QVMClient) -> ExecutionData:
|
|
49
|
+
"""
|
|
50
|
+
Execute on a QVM which is accessible via the provided client.
|
|
51
|
+
|
|
52
|
+
:raises `ExecutionError`: If the job fails to execute.
|
|
53
|
+
"""
|
|
54
|
+
...
|
|
55
|
+
async def execute_on_qvm_async(self, client: QVMClient) -> ExecutionData:
|
|
56
|
+
"""
|
|
57
|
+
Execute on a QVM which is accessible via the provided client.
|
|
58
|
+
(async analog of ``Executable.execute_on_qvm``.)
|
|
59
|
+
|
|
60
|
+
:raises `ExecutionError`: If the job fails to execute.
|
|
61
|
+
"""
|
|
62
|
+
...
|
|
63
|
+
def execute_on_qpu(
|
|
64
|
+
self,
|
|
65
|
+
quantum_processor_id: str,
|
|
66
|
+
endpoint_id: Optional[str] = None,
|
|
67
|
+
translation_options: Optional[TranslationOptions] = None,
|
|
68
|
+
execution_options: Optional[ExecutionOptions] = None,
|
|
69
|
+
) -> ExecutionData:
|
|
70
|
+
"""
|
|
71
|
+
Compile the program and execute it on a QPU, waiting for results.
|
|
72
|
+
|
|
73
|
+
:param endpoint_id: execute the compiled program against an explicitly provided endpoint. If `None`,
|
|
74
|
+
the default endpoint for the given quantum_processor_id is used.
|
|
75
|
+
|
|
76
|
+
:raises `ExecutionError`: If the job fails to execute.
|
|
77
|
+
"""
|
|
78
|
+
...
|
|
79
|
+
async def execute_on_qpu_async(
|
|
80
|
+
self,
|
|
81
|
+
quantum_processor_id: str,
|
|
82
|
+
endpoint_id: Optional[str] = None,
|
|
83
|
+
translation_options: Optional[TranslationOptions] = None,
|
|
84
|
+
execution_options: Optional[ExecutionOptions] = None,
|
|
85
|
+
) -> ExecutionData:
|
|
86
|
+
"""
|
|
87
|
+
Compile the program and execute it on a QPU, waiting for results.
|
|
88
|
+
(async analog of `Executable.execute_on_qpu`)
|
|
89
|
+
|
|
90
|
+
:param endpoint_id: execute the compiled program against an explicitly provided endpoint. If `None`,
|
|
91
|
+
the default endpoint for the given quantum_processor_id is used.
|
|
92
|
+
|
|
93
|
+
:raises `ExecutionError`: If the job fails to execute.
|
|
94
|
+
"""
|
|
95
|
+
...
|
|
96
|
+
def submit_to_qpu(
|
|
97
|
+
self,
|
|
98
|
+
quantum_processor_id: str,
|
|
99
|
+
endpoint_id: Optional[str] = None,
|
|
100
|
+
translation_options: Optional[TranslationOptions] = None,
|
|
101
|
+
execution_options: Optional[ExecutionOptions] = None,
|
|
102
|
+
) -> JobHandle:
|
|
103
|
+
"""
|
|
104
|
+
Compile the program and execute it on a QPU, without waiting for results.
|
|
105
|
+
|
|
106
|
+
:param endpoint_id: execute the compiled program against an explicitly provided endpoint. If `None`,
|
|
107
|
+
the default endpoint for the given quantum_processor_id is used.
|
|
108
|
+
|
|
109
|
+
:raises `ExecutionError`: If the job fails to execute.
|
|
110
|
+
"""
|
|
111
|
+
...
|
|
112
|
+
async def submit_to_qpu_async(
|
|
113
|
+
self,
|
|
114
|
+
quantum_processor_id: str,
|
|
115
|
+
endpoint_id: Optional[str] = None,
|
|
116
|
+
translation_options: Optional[TranslationOptions] = None,
|
|
117
|
+
execution_options: Optional[ExecutionOptions] = None,
|
|
118
|
+
) -> JobHandle:
|
|
119
|
+
"""
|
|
120
|
+
Compile the program and execute it on a QPU, without waiting for results.
|
|
121
|
+
(async analog of `Executable.execute_on_qpu`)
|
|
122
|
+
|
|
123
|
+
:param endpoint_id: execute the compiled program against an explicitly provided endpoint. If `None`,
|
|
124
|
+
the default endpoint for the given quantum_processor_id is used.
|
|
125
|
+
|
|
126
|
+
:raises `ExecutionError`: If the job fails to execute.
|
|
127
|
+
"""
|
|
128
|
+
...
|
|
129
|
+
def retrieve_results(self, job_handle: JobHandle) -> ExecutionData:
|
|
130
|
+
"""
|
|
131
|
+
Wait for the results of a job to complete.
|
|
132
|
+
|
|
133
|
+
:raises `ExecutionError`: If the job fails to execute.
|
|
134
|
+
"""
|
|
135
|
+
...
|
|
136
|
+
async def retrieve_results_async(self, job_handle: JobHandle) -> ExecutionData:
|
|
137
|
+
"""
|
|
138
|
+
Wait for the results of a job to complete.
|
|
139
|
+
(async analog of `Executable.retrieve_results`)
|
|
140
|
+
|
|
141
|
+
:raises `ExecutionError`: If the job fails to execute.
|
|
142
|
+
"""
|
|
143
|
+
...
|
|
144
|
+
|
|
145
|
+
@final
|
|
146
|
+
class JobHandle:
|
|
147
|
+
"""
|
|
148
|
+
The result of submitting a job to a QPU.
|
|
149
|
+
|
|
150
|
+
Used to retrieve the results of a job.
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def job_id(self) -> str:
|
|
155
|
+
"""
|
|
156
|
+
Unique ID associated with a single job execution.
|
|
157
|
+
"""
|
|
158
|
+
...
|
|
159
|
+
@property
|
|
160
|
+
def readout_map(self) -> Dict[str, str]:
|
|
161
|
+
"""
|
|
162
|
+
The readout map from source readout memory locations to the filter pipeline node
|
|
163
|
+
which publishes the data.
|
|
164
|
+
"""
|
|
165
|
+
...
|
|
166
|
+
|
|
167
|
+
@final
|
|
168
|
+
class ExeParameter:
|
|
169
|
+
"""
|
|
170
|
+
Program execution parameters.
|
|
171
|
+
|
|
172
|
+
Note: The validity of parameters is not checked until execution.
|
|
173
|
+
"""
|
|
174
|
+
|
|
175
|
+
def __new__(
|
|
176
|
+
cls,
|
|
177
|
+
name: str,
|
|
178
|
+
index: int,
|
|
179
|
+
value: float,
|
|
180
|
+
) -> "ExeParameter": ...
|
|
181
|
+
@property
|
|
182
|
+
def name(self) -> str: ...
|
|
183
|
+
@name.setter
|
|
184
|
+
def name(self, value: str): ...
|
|
185
|
+
@property
|
|
186
|
+
def index(self) -> int: ...
|
|
187
|
+
@index.setter
|
|
188
|
+
def index(self, value: int): ...
|
|
189
|
+
@property
|
|
190
|
+
def value(self) -> float: ...
|
|
191
|
+
@value.setter
|
|
192
|
+
def value(self, value: float): ...
|
|
193
|
+
|
|
194
|
+
@final
|
|
195
|
+
class Service(Enum):
|
|
196
|
+
Quilc = "Quilc"
|
|
197
|
+
QVM = "QVM"
|
|
198
|
+
QCS = "QCS"
|
|
199
|
+
QPU = "QPU"
|
|
200
|
+
|
|
201
|
+
class RegisterMatrixConversionError(ValueError):
|
|
202
|
+
"""Error that may occur when building a `RegisterMatrix` from execution data."""
|
|
203
|
+
|
|
204
|
+
...
|
|
205
|
+
|
|
206
|
+
@final
|
|
207
|
+
class RegisterMatrix:
|
|
208
|
+
"""
|
|
209
|
+
Values in a 2-dimensional ``ndarray`` representing the final shot value in each memory reference across all shots.
|
|
210
|
+
Each variant corresponds to the possible data types a register can contain.
|
|
211
|
+
|
|
212
|
+
## Variants:
|
|
213
|
+
- ``integer``: Corresponds to the Quil ``BIT``, ``OCTET``, or ``INTEGER`` types.
|
|
214
|
+
- ``real``: Corresponds to the Quil ``REAL`` type.
|
|
215
|
+
- ``complex``: Registers containing complex numbers.
|
|
216
|
+
|
|
217
|
+
### Methods (each per variant):
|
|
218
|
+
- ``is_*``: if the underlying values are that type.
|
|
219
|
+
- ``as_*``: if the underlying values are that type, then those values, otherwise ``None``.
|
|
220
|
+
- ``to_*``: the underlying values as that type, raises ``ValueError`` if they are not.
|
|
221
|
+
- ``from_*``: wrap underlying values as this enum type.
|
|
222
|
+
|
|
223
|
+
"""
|
|
224
|
+
|
|
225
|
+
def is_integer(self) -> bool: ...
|
|
226
|
+
def is_real(self) -> bool: ...
|
|
227
|
+
def is_complex(self) -> bool: ...
|
|
228
|
+
def as_integer(self) -> Optional[NDArray[np.int64]]: ...
|
|
229
|
+
def as_real(self) -> Optional[NDArray[np.float64]]: ...
|
|
230
|
+
# In numpy `complex128` is a complex number made up of two `f64`s.
|
|
231
|
+
def as_complex(self) -> Optional[NDArray[np.complex128]]: ...
|
|
232
|
+
def to_integer(self) -> NDArray[np.int64]: ...
|
|
233
|
+
def to_real(self) -> NDArray[np.float64]: ...
|
|
234
|
+
def to_complex(self) -> NDArray[np.complex128]: ...
|
|
235
|
+
@staticmethod
|
|
236
|
+
def from_integer(inner: NDArray[np.int64]) -> "RegisterMatrix": ...
|
|
237
|
+
@staticmethod
|
|
238
|
+
def from_real(inner: NDArray[np.float64]) -> "RegisterMatrix": ...
|
|
239
|
+
@staticmethod
|
|
240
|
+
def from_complex(inner: NDArray[np.complex128]) -> "RegisterMatrix": ...
|
|
241
|
+
def to_ndarray(self) -> Union[NDArray[np.complex128], NDArray[np.int64], NDArray[np.float64]]:
|
|
242
|
+
"""
|
|
243
|
+
Get the RegisterMatrix as numpy ``ndarray``.
|
|
244
|
+
"""
|
|
245
|
+
...
|
|
246
|
+
|
|
247
|
+
@final
|
|
248
|
+
class RegisterMap:
|
|
249
|
+
"""A map of register names (ie. "ro") to a `RegisterMatrix` containing the values of the register."""
|
|
250
|
+
|
|
251
|
+
def get_register_matrix(self, register_name: str) -> Optional[RegisterMatrix]:
|
|
252
|
+
"""Get the ``RegisterMatrix`` for the given register. Returns `None` if the register doesn't exist."""
|
|
253
|
+
...
|
|
254
|
+
def get(self, key: str, default: Optional[RegisterMatrix] = None) -> Optional[RegisterMatrix]: ...
|
|
255
|
+
def items(self) -> Iterable[Tuple[str, RegisterMatrix]]: ...
|
|
256
|
+
def keys(self) -> Iterable[str]: ...
|
|
257
|
+
def values(self) -> Iterable[RegisterMatrix]: ...
|
|
258
|
+
def __iter__(self) -> Iterable[str]: ...
|
|
259
|
+
def __getitem__(self, item: str) -> RegisterMatrix: ...
|
|
260
|
+
def __contains__(self, key: str) -> bool: ...
|
|
261
|
+
def __len__(self) -> int: ...
|
|
262
|
+
|
|
263
|
+
@final
|
|
264
|
+
class ResultData:
|
|
265
|
+
"""
|
|
266
|
+
Represents the two possible types of data returned from either the QVM or a real QPU.
|
|
267
|
+
Each variant contains the original data returned from its respective executor.
|
|
268
|
+
|
|
269
|
+
## Usage
|
|
270
|
+
|
|
271
|
+
Your usage of `ResultData` will depend on the types of programs you are running and where.
|
|
272
|
+
The `ResultData.to_register_map()` method will attempt to build `RegisterMap` out of the data, where each
|
|
273
|
+
register name is mapped to a 2-dimensional rectangular `RegisterMatrix` where each row
|
|
274
|
+
represents the final values in each register index for a particular shot. This is often the
|
|
275
|
+
desired form of the data and it is <em>probably</em> what you want. This transformation isn't always
|
|
276
|
+
possible, in which case `to_register_map()` will return an error.
|
|
277
|
+
|
|
278
|
+
To understand why this transformation can fail, we need to understand a bit about how readout data is
|
|
279
|
+
returned from the QVM and from a real QPU:
|
|
280
|
+
|
|
281
|
+
The QVM treats each `DECLARE` statement as initialzing some amount of memory. This memory works
|
|
282
|
+
as one might expect it to. It is zero-initalized, and subsequent writes to the same region
|
|
283
|
+
overwrite the previous value. The QVM returns memory at the end of every shot. This means
|
|
284
|
+
we get the last value in every memory reference for each shot, which is exactly the
|
|
285
|
+
representation we want for a `RegisterMatrix`. For this reason, `to_register_map()` should
|
|
286
|
+
always succeed for `ResultData::Qvm`.
|
|
287
|
+
|
|
288
|
+
The QPU on the other hand doesn't use the same memory model as the QVM. Each memory reference
|
|
289
|
+
(ie. "ro[0]") is more like a stream than a value in memory. Every `MEASURE` to a memory
|
|
290
|
+
reference emits a new value to said stream. This means that the number of values per memory
|
|
291
|
+
reference can vary per shot. For this reason, it's not always clear what the final value in
|
|
292
|
+
each shot was for a particular reference. When this is the case, `to_register_map()` will return
|
|
293
|
+
an error as it's impossible to build a correct ``RegisterMatrix`` from the data without
|
|
294
|
+
knowing the intent of the program that was run. Instead, it's recommended to build the
|
|
295
|
+
``RegisterMatrix`` you need from the inner ``QPUResultData`` data using the knowledge of your
|
|
296
|
+
program to choose the correct readout values for each shot.
|
|
297
|
+
|
|
298
|
+
For more information on QPU readout data, refer to the
|
|
299
|
+
[QCS Documentation](https://docs.rigetti.com/qcs/guides/qpus-vs-qvms#qpu-readout-data).
|
|
300
|
+
|
|
301
|
+
### Variants:
|
|
302
|
+
- ``qvm``: Data returned from the QVM, stored as ``QVMResultData``
|
|
303
|
+
- ``qpu``: Data returned from the QPU, stored as ``QPUResultData``
|
|
304
|
+
|
|
305
|
+
### Methods (each per variant):
|
|
306
|
+
- ``is_*``: if the underlying values are that type.
|
|
307
|
+
- ``as_*``: if the underlying values are that type, then those values, otherwise ``None``.
|
|
308
|
+
- ``to_*``: the underlying values as that type, raises ``ValueError`` if they are not.
|
|
309
|
+
- ``from_*``: wrap underlying values as this enum type.
|
|
310
|
+
"""
|
|
311
|
+
|
|
312
|
+
def __new__(cls, inner: Union[QPUResultData, QVMResultData]) -> "ResultData":
|
|
313
|
+
"""
|
|
314
|
+
Create a new ResultData from either QVM or QPU result data.
|
|
315
|
+
"""
|
|
316
|
+
...
|
|
317
|
+
def to_register_map(self) -> RegisterMap:
|
|
318
|
+
"""
|
|
319
|
+
Convert `ResultData` from its inner representation as `QVMResultData` or
|
|
320
|
+
`QPUResultData` into a `RegisterMap`. The `RegisterMatrix` for each register will be
|
|
321
|
+
constructed such that each row contains all the final values in the register for a single shot.
|
|
322
|
+
|
|
323
|
+
## Errors
|
|
324
|
+
|
|
325
|
+
Raises a `RegisterMatrixConversionError` if the inner execution data for any of the
|
|
326
|
+
registers would result in a jagged matrix. `QPUResultData` data is captured per measure,
|
|
327
|
+
meaning a value is returned for every measure to a memory reference, not just once per shot.
|
|
328
|
+
This is often the case in programs that use mid-circuit measurement or dynamic control flow,
|
|
329
|
+
where measurements to the same memory reference might occur multiple times in a shot, or be
|
|
330
|
+
skipped conditionally. In these cases, building a rectangular `RegisterMatrix` would
|
|
331
|
+
necessitate making assumptions about the data that could skew the data in undesirable ways.
|
|
332
|
+
Instead, it's recommended to manually build a matrix from `QPUResultData` that accurately
|
|
333
|
+
selects the last value per-shot based on the program that was run.
|
|
334
|
+
"""
|
|
335
|
+
...
|
|
336
|
+
def to_raw_readout_data(self) -> Union[RawQPUReadoutData, RawQVMReadoutData]:
|
|
337
|
+
"""
|
|
338
|
+
Get the raw data returned from the QVM or QPU. See `RawQPUReadoutData` and
|
|
339
|
+
`RawQVMReadoutData` for more information.
|
|
340
|
+
"""
|
|
341
|
+
def inner(
|
|
342
|
+
self,
|
|
343
|
+
) -> Union[QVMResultData, QPUResultData]:
|
|
344
|
+
"""Returns the inner result data"""
|
|
345
|
+
...
|
|
346
|
+
def is_qvm(self) -> bool: ...
|
|
347
|
+
def is_qpu(self) -> bool: ...
|
|
348
|
+
def as_qvm(self) -> Optional[QVMResultData]: ...
|
|
349
|
+
def as_qpu(self) -> Optional[QPUResultData]: ...
|
|
350
|
+
def to_qvm(self) -> QVMResultData: ...
|
|
351
|
+
def to_qpu(self) -> QPUResultData: ...
|
|
352
|
+
@staticmethod
|
|
353
|
+
def from_qvm(inner: QVMResultData) -> "ResultData": ...
|
|
354
|
+
@staticmethod
|
|
355
|
+
def from_qpu(inner: QPUResultData) -> "ResultData": ...
|
|
356
|
+
|
|
357
|
+
@final
|
|
358
|
+
class ExecutionData:
|
|
359
|
+
"""
|
|
360
|
+
Contains the `ResultData` and the duration of the execution.
|
|
361
|
+
"""
|
|
362
|
+
|
|
363
|
+
def __new__(cls, result_data: ResultData, duration: Optional[datetime.timedelta] = None): ...
|
|
364
|
+
@property
|
|
365
|
+
def result_data(self) -> ResultData: ...
|
|
366
|
+
@result_data.setter
|
|
367
|
+
def result_data(self, result_data: ResultData): ...
|
|
368
|
+
@property
|
|
369
|
+
def duration(self) -> Optional[datetime.timedelta]: ...
|
|
370
|
+
@duration.setter
|
|
371
|
+
def duration(self, duration: Optional[datetime.timedelta]): ...
|
|
372
|
+
|
|
373
|
+
@final
|
|
374
|
+
class RegisterData:
|
|
375
|
+
"""
|
|
376
|
+
Values present in a register that are one of a set of variants.
|
|
377
|
+
|
|
378
|
+
Variants:
|
|
379
|
+
- ``i8``: Corresponds to the Quil ``BIT`` or ``OCTET`` types.
|
|
380
|
+
- ``i16``: Corresponds to the Quil ``INTEGER`` type.
|
|
381
|
+
- ``f64``: Corresponds to the Quil ``REAL`` type.
|
|
382
|
+
- ``complex32``: Results containing complex numbers.
|
|
383
|
+
|
|
384
|
+
Methods (each per variant):
|
|
385
|
+
- ``is_*``: if the underlying values are that type.
|
|
386
|
+
- ``as_*``: if the underlying values are that type, then those values, otherwise ``None``.
|
|
387
|
+
- ``to_*``: the underlying values as that type, raises ``ValueError`` if they are not.
|
|
388
|
+
- ``from_*``: wrap underlying values as this enum type.
|
|
389
|
+
"""
|
|
390
|
+
|
|
391
|
+
def __new__(cls, inner: Union[List[List[int]], List[List[float]], List[List[complex]]]) -> "RegisterData": ...
|
|
392
|
+
def inner(
|
|
393
|
+
self,
|
|
394
|
+
) -> Union[List[List[int]], List[List[float]], List[List[complex]]]:
|
|
395
|
+
"""Returns the inner value."""
|
|
396
|
+
...
|
|
397
|
+
def as_ndarray(self) -> Union[NDArray[np.int64], NDArray[np.float64], NDArray[np.complex128]]:
|
|
398
|
+
"""Returns the values as an ``ndarray``."""
|
|
399
|
+
...
|
|
400
|
+
def is_i8(self) -> bool: ...
|
|
401
|
+
def is_i16(self) -> bool: ...
|
|
402
|
+
def is_f64(self) -> bool: ...
|
|
403
|
+
def is_complex32(self) -> bool: ...
|
|
404
|
+
def as_i8(self) -> Optional[List[List[int]]]: ...
|
|
405
|
+
def as_i16(self) -> Optional[List[List[int]]]: ...
|
|
406
|
+
def as_f64(self) -> Optional[List[List[float]]]: ...
|
|
407
|
+
def as_complex32(self) -> Optional[List[List[complex]]]: ...
|
|
408
|
+
def to_i8(self) -> List[List[int]]: ...
|
|
409
|
+
def to_i16(self) -> List[List[int]]: ...
|
|
410
|
+
def to_f64(self) -> List[List[float]]: ...
|
|
411
|
+
def to_complex32(self) -> List[List[complex]]: ...
|
|
412
|
+
@staticmethod
|
|
413
|
+
def from_i8(inner: Sequence[Sequence[int]]) -> "RegisterData": ...
|
|
414
|
+
@staticmethod
|
|
415
|
+
def from_i16(inner: Sequence[Sequence[int]]) -> "RegisterData": ...
|
|
416
|
+
@staticmethod
|
|
417
|
+
def from_f64(inner: Sequence[Sequence[float]]) -> "RegisterData": ...
|
|
418
|
+
@staticmethod
|
|
419
|
+
def from_complex32(inner: Sequence[Sequence[complex]]) -> "RegisterData": ...
|
|
420
|
+
|
|
421
|
+
def reset_logging():
|
|
422
|
+
"""
|
|
423
|
+
Reset all caches for logging configuration within this library, allowing the most recent Python-side
|
|
424
|
+
changes to be applied.
|
|
425
|
+
|
|
426
|
+
See <https://docs.rs/pyo3-log/latest/pyo3_log/> for more information.
|
|
427
|
+
"""
|
qcs_sdk/client.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from qcs_sdk.client import *
|
qcs_sdk/client.pyi
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
from typing import Optional, final
|
|
2
|
+
|
|
3
|
+
class LoadClientError(RuntimeError):
|
|
4
|
+
"""Error encountered while loading the QCS API client configuration from the environment configuration."""
|
|
5
|
+
|
|
6
|
+
...
|
|
7
|
+
|
|
8
|
+
class BuildClientError(RuntimeError):
|
|
9
|
+
"""Error encountered while building the QCS API client configuration manually."""
|
|
10
|
+
|
|
11
|
+
...
|
|
12
|
+
|
|
13
|
+
@final
|
|
14
|
+
class QCSClient:
|
|
15
|
+
"""
|
|
16
|
+
Configuration for connecting and authenticating to QCS APIs and resources.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __new__(
|
|
20
|
+
cls,
|
|
21
|
+
tokens: Optional[QCSClientTokens] = None,
|
|
22
|
+
api_url: Optional[str] = None,
|
|
23
|
+
auth_server: Optional[QCSClientAuthServer] = None,
|
|
24
|
+
grpc_api_url: Optional[str] = None,
|
|
25
|
+
quilc_url: Optional[str] = None,
|
|
26
|
+
qvm_url: Optional[str] = None,
|
|
27
|
+
) -> "QCSClient":
|
|
28
|
+
"""
|
|
29
|
+
Manually construct a `QCSClient`.
|
|
30
|
+
|
|
31
|
+
Prefer to use `QCSClient.load` to construct an environment-based profile.
|
|
32
|
+
"""
|
|
33
|
+
...
|
|
34
|
+
@staticmethod
|
|
35
|
+
def load(
|
|
36
|
+
profile_name: Optional[str] = None,
|
|
37
|
+
) -> "QCSClient":
|
|
38
|
+
"""
|
|
39
|
+
Create a `QCSClient` configuration using an environment-based configuration.
|
|
40
|
+
|
|
41
|
+
:param profile_name: The QCS setting's profile name to use. If ``None``, the default value configured in your environment is used.
|
|
42
|
+
|
|
43
|
+
:raises `LoadClientError`: If there is an issue loading the profile defails from the environment.
|
|
44
|
+
|
|
45
|
+
See the [QCS documentation](https://docs.rigetti.com/qcs/references/qcs-client-configuration#environment-variables-and-configuration-files)
|
|
46
|
+
for more details.
|
|
47
|
+
"""
|
|
48
|
+
...
|
|
49
|
+
@staticmethod
|
|
50
|
+
async def load_async(
|
|
51
|
+
profile_name: Optional[str] = None,
|
|
52
|
+
) -> "QCSClient":
|
|
53
|
+
"""
|
|
54
|
+
Create a `QCSClient` configuration using an environment-based configuration.
|
|
55
|
+
(async analog of `QCSClient.load`)
|
|
56
|
+
|
|
57
|
+
:param profile_name: The QCS setting's profile name to use. If `None`, the default value configured in your environment is used.
|
|
58
|
+
|
|
59
|
+
:raises `LoadClientError`: If there is an issue loading the profile defails from the environment.
|
|
60
|
+
|
|
61
|
+
See the [QCS documentation](https://docs.rigetti.com/qcs/references/qcs-client-configuration#environment-variables-and-configuration-files)
|
|
62
|
+
for more details.
|
|
63
|
+
"""
|
|
64
|
+
...
|
|
65
|
+
@property
|
|
66
|
+
def api_url(self) -> str:
|
|
67
|
+
"""URL to access the QCS API."""
|
|
68
|
+
...
|
|
69
|
+
@property
|
|
70
|
+
def grpc_api_url(self) -> str:
|
|
71
|
+
"""URL to access the QCS gRPC API."""
|
|
72
|
+
...
|
|
73
|
+
@property
|
|
74
|
+
def quilc_url(self) -> str:
|
|
75
|
+
"""URL to access the ``quilc`1 compiler."""
|
|
76
|
+
...
|
|
77
|
+
@property
|
|
78
|
+
def qvm_url(self) -> str:
|
|
79
|
+
"""URL to access the QVM."""
|
|
80
|
+
...
|
|
81
|
+
|
|
82
|
+
@final
|
|
83
|
+
class QCSClientAuthServer:
|
|
84
|
+
"""Authentication server configuration for the QCS API."""
|
|
85
|
+
|
|
86
|
+
def __new__(cls, client_id: str, issuer: str) -> "QCSClientAuthServer":
|
|
87
|
+
"""
|
|
88
|
+
Manually define authentication server parameters.
|
|
89
|
+
|
|
90
|
+
:param client_id: The OAuth application client ID. If `None`, a default value is used.
|
|
91
|
+
:param issuer: The OAuth token issuer url. If `None`, a default value is used.
|
|
92
|
+
"""
|
|
93
|
+
...
|
|
94
|
+
@property
|
|
95
|
+
def client_id(self) -> str: ...
|
|
96
|
+
@client_id.setter
|
|
97
|
+
def client_id(self, value: str): ...
|
|
98
|
+
@property
|
|
99
|
+
def issuer(self) -> str: ...
|
|
100
|
+
@issuer.setter
|
|
101
|
+
def issuer(self, value: str): ...
|
|
102
|
+
|
|
103
|
+
@final
|
|
104
|
+
class QCSClientTokens:
|
|
105
|
+
"""Authentication tokens for the QCS API."""
|
|
106
|
+
|
|
107
|
+
def __new__(
|
|
108
|
+
cls,
|
|
109
|
+
bearer_access_token: str,
|
|
110
|
+
refresh_token: str,
|
|
111
|
+
) -> "QCSClientTokens":
|
|
112
|
+
"""
|
|
113
|
+
Manually define authentication session tokens.
|
|
114
|
+
|
|
115
|
+
:param bearer_access_token: The session token from an OAuth issuer.
|
|
116
|
+
:param refresh_token: A credential to refresh the bearer_access_token when it expires.
|
|
117
|
+
"""
|
|
118
|
+
...
|
|
119
|
+
@property
|
|
120
|
+
def bearer_access_token(self) -> Optional[str]: ...
|
|
121
|
+
@bearer_access_token.setter
|
|
122
|
+
def bearer_access_token(self, value: Optional[str]): ...
|
|
123
|
+
@property
|
|
124
|
+
def refresh_token(self) -> Optional[str]: ...
|
|
125
|
+
@refresh_token.setter
|
|
126
|
+
def refresh_token(self, value: Optional[str]): ...
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module for interacting with the Quil Compiler (quilc).
|
|
3
|
+
|
|
4
|
+
🔨 This page is under construction. In the meantime, you can find documentation
|
|
5
|
+
in the [the type hints](https://github.com/rigetti/qcs-sdk-rust/blob/main/crates/python/qcs_sdk/compiler/quilc.pyi).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from qcs_sdk.compiler import quilc
|