qcs 0.26.1

High level interface for running Quil on a QPU
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501, F401

import builtins
import collections.abc
import datetime
import typing
from qcs_sdk import QcsSdkError
from qcs_sdk.client import QCSClient
from qcs_sdk.qpu import MemoryValues

@typing.final
class APIExecutionOptions:
    r"""
    Options available when executing a job on a QPU, particular to the execution service's API.
    
    This is a conventent alias for [`InnerApiExecutionOptions`] which provides a builder.
    
    Use [`Default`] to get a reasonable set of defaults, or start with [`ApiExecutionOptionsBuilder`]
    to build a custom set of options.
    """
    @property
    def bypass_settings_protection(self) -> builtins.bool:
        r"""
        Get the configured `bypass_settings_protection` value.
        """
    @property
    def timeout(self) -> typing.Optional[QpuApiDuration]:
        r"""
        Get the configured `timeout` value.
        
        Note, this is the timeout while running a job; the job will be evicted from
        the hardware once this time has elapsed.
        
        If unset, the job's estimated duration will be used;
        if the job does not have an estimated duration, the default
        timeout is selected by the service.
        
        The service may also enforce a maximum value for this field.
        """
    def __new__(cls, bypass_settings_protection: builtins.bool = False, timeout: typing.Optional[datetime.timedelta] = None) -> APIExecutionOptions: ...
    def __repr__(self) -> builtins.str:
        r"""
        Implements `__repr__` for Python in terms of the Rust
        [`Debug`](std::fmt::Debug) implementation.
        """
    @staticmethod
    def builder() -> APIExecutionOptionsBuilder:
        r"""
        Get an [`ExecutionOptionsBuilder`] that can be used to build a custom [`ExecutionOptions`].
        """
    @staticmethod
    def default() -> APIExecutionOptions: ...

@typing.final
class APIExecutionOptionsBuilder:
    r"""
    Builder for [`ApiExecutionOptions`](struct.ApiExecutionOptions.html).
    """
    @property
    def bypass_settings_protection(self) -> typing.Never:
        r"""
        DO NOT CALL THIS METHOD.
        
        `mypy` requires write-only properties to have a getter,
        but this method is not actually available at runtime.
        """
    @bypass_settings_protection.setter
    def bypass_settings_protection(self, value: builtins.bool) -> None: ...
    @property
    def timeout(self) -> typing.Never:
        r"""
        DO NOT CALL THIS METHOD.
        
        `mypy` requires write-only properties to have a getter,
        but this method is not actually available at runtime.
        """
    @timeout.setter
    def timeout(self, value: typing.Optional[QpuApiDuration]) -> None: ...
    def __new__(cls) -> APIExecutionOptionsBuilder: ...
    def build(self) -> APIExecutionOptions: ...
    @staticmethod
    def default() -> APIExecutionOptionsBuilder: ...

class BuildOptionsError(QpuApiError):
    r"""
    Errors building execution options.
    """
    ...

class ConnectionStrategy:
    r"""
    The connection strategy to use when submitting and retrieving jobs from a QPU.
    """
    def __getnewargs__(self) -> tuple[str] | tuple[()]: ...
    def __repr__(self) -> builtins.str:
        r"""
        Implements `__repr__` for Python in terms of the Rust
        [`Debug`](std::fmt::Debug) implementation.
        """
    @staticmethod
    def default() -> ConnectionStrategy: ...
    def get_endpoint_id(self) -> builtins.str: ...
    @typing.final
    class DirectAccess(ConnectionStrategy):
        r"""
        Connect directly to the default endpoint, bypassing the gateway. Should only be used when you
        have direct network access and an active reservation.
        """
        __match_args__ = ()
        def __getitem__(self, key: builtins.int) -> typing.Any: ...
        def __len__(self) -> builtins.int: ...
        def __new__(cls) -> ConnectionStrategy.DirectAccess: ...
    
    @typing.final
    class EndpointAddress(ConnectionStrategy):
        r"""
        Connect directly to a specific endpoint by its gRPC address, bypassing the gateway.
        
        Should only be used when you have direct network access.
        """
        __match_args__ = ("_0",)
        @property
        def _0(self) -> builtins.str: ...
        def __getitem__(self, key: builtins.int) -> typing.Any: ...
        def __len__(self) -> builtins.int: ...
        def __new__(cls, _0: builtins.str) -> ConnectionStrategy.EndpointAddress: ...
        
    @typing.final
    class EndpointId(ConnectionStrategy):
        r"""
        Connect directly to a specific endpoint using its ID.
        """
        __match_args__ = ("_0",)
        @property
        def _0(self) -> builtins.str: ...
        def __getitem__(self, key: builtins.int) -> typing.Any: ...
        def __len__(self) -> builtins.int: ...
        def __new__(cls, _0: builtins.str) -> ConnectionStrategy.EndpointId: ...
    
    @typing.final
    class Gateway(ConnectionStrategy):
        r"""
        Connect through the publicly accessible gateway.
        """
        __match_args__ = ()
        def __getitem__(self, key: builtins.int) -> typing.Any: ...
        def __len__(self) -> builtins.int: ...
        def __new__(cls) -> ConnectionStrategy.Gateway: ...
    

@typing.final
class ExecutionOptions:
    r"""
    Options available when executing a job on a QPU.
    
    Use [`Default`] to get a reasonable set of defaults, or start with [`ExecutionOptionsBuilder`]
    to build a custom set of options.
    """
    @property
    def api_options(self) -> typing.Optional[APIExecutionOptions]: ...
    @property
    def connection_strategy(self) -> ConnectionStrategy:
        r"""
        The [`ConnectionStrategy`] to use to establish a connection to the QPU.
        """
    @property
    def timeout_seconds(self) -> typing.Optional[builtins.float]: ...
    def __eq__(self, other: builtins.object) -> builtins.bool: ...
    def __getnewargs__(self) -> tuple[ConnectionStrategy, typing.Optional[datetime.timedelta], typing.Optional[APIExecutionOptions]]: ...
    def __new__(cls, connection_strategy: ConnectionStrategy = ..., timeout: typing.Optional[datetime.timedelta] = ..., api_options: typing.Optional[APIExecutionOptions] = None) -> ExecutionOptions: ...
    def __repr__(self) -> builtins.str:
        r"""
        Implements `__repr__` for Python in terms of the Rust
        [`Debug`](std::fmt::Debug) implementation.
        """
    @staticmethod
    def builder() -> ExecutionOptionsBuilder: ...
    @staticmethod
    def default() -> ExecutionOptions: ...

@typing.final
class ExecutionOptionsBuilder:
    r"""
    Builder for [`ExecutionOptions`](struct.ExecutionOptions.html).
    """
    @property
    def api_options(self) -> typing.Never:
        r"""
        DO NOT CALL THIS METHOD.
        
        `mypy` requires write-only properties to have a getter,
        but this method is not actually available at runtime.
        """
    @api_options.setter
    def api_options(self, value: typing.Optional[APIExecutionOptions]) -> None: ...
    @property
    def connection_strategy(self) -> typing.Never:
        r"""
        DO NOT CALL THIS METHOD.
        
        `mypy` requires write-only properties to have a getter,
        but this method is not actually available at runtime.
        """
    @connection_strategy.setter
    def connection_strategy(self, value: ConnectionStrategy) -> None: ...
    @property
    def timeout_seconds(self) -> typing.Never:
        r"""
        DO NOT CALL THIS METHOD.
        
        `mypy` requires write-only properties to have a getter,
        but this method is not actually available at runtime.
        """
    @timeout_seconds.setter
    def timeout_seconds(self, value: typing.Optional[builtins.float]) -> None: ...
    def __new__(cls) -> ExecutionOptionsBuilder: ...
    def build(self) -> ExecutionOptions: ...
    @staticmethod
    def default() -> ExecutionOptionsBuilder: ...

@typing.final
class ExecutionResult:
    r"""
    Execution readout data from a particular memory location.
    """
    @property
    def data(self) -> builtins.list[builtins.int] | builtins.list[builtins.complex]:
        r"""
        The result data for all shots by the particular memory location.
        """
    @property
    def dtype(self) -> builtins.str:
        r"""
        The type of the result data (as a `numpy` `dtype`).
        """
    @property
    def shape(self) -> builtins.list[builtins.int]:
        r"""
        The shape of the result data.
        """
    def __getnewargs__(self) -> tuple[builtins.list[builtins.int] | builtins.list[builtins.complex]]: ...
    def __new__(cls, register: typing.Sequence[builtins.int] | typing.Sequence[builtins.complex]) -> ExecutionResult: ...
    @staticmethod
    def from_register(register: typing.Sequence[builtins.int] | typing.Sequence[builtins.complex]) -> ExecutionResult:
        r"""
        Build an `ExecutionResult` from a `Register`.
        """

@typing.final
class ExecutionResults:
    r"""
    Execution readout data for all memory locations.
    """
    @property
    def buffers(self) -> builtins.dict[builtins.str, ExecutionResult]:
        r"""
        The readout results of execution, mapping a published filter node to its data.
        
        See `TranslationResult.ro_sources` which provides the mapping from the filter node name
        to the name of the memory declaration in the source program.
        """
    @property
    def execution_duration_microseconds(self) -> typing.Optional[builtins.int]:
        r"""
        The time spent executing the program.
        """
    @property
    def memory(self) -> builtins.dict[builtins.str, MemoryValues]:
        r"""
        The final state of memory for parameters that were read from and written to during
        the execution of the program.
        """
    def __new__(cls, buffers: typing.Mapping[builtins.str, ExecutionResult], memory: typing.Mapping[builtins.str, MemoryValues], execution_duration_microseconds: typing.Optional[builtins.int] = None) -> ExecutionResults: ...

@typing.final
class QpuApiDuration:
    r"""
    The duration of an API call.
    """
    @property
    def nanos(self) -> builtins.int: ...
    @property
    def seconds(self) -> builtins.int: ...
    def __new__(cls, seconds: builtins.int, nanos: builtins.int) -> QpuApiDuration: ...

class QpuApiError(QcsSdkError):
    r"""
    Errors that can occur while attempting to establish a connection to the QPU.
    """
    ...

class SubmissionError(QpuApiError):
    r"""
    Errors that may occur when submitting a program for execution.
    """
    ...

def cancel_job(job_id: builtins.str, quantum_processor_id: typing.Optional[builtins.str] = None, client: typing.Optional[QCSClient] = None, execution_options: typing.Optional[ExecutionOptions] = None) -> None:
    r"""
    Cancel a job that has yet to begin executing.
    
    This action is *not* atomic, and will attempt to cancel a job even if it cannot be cancelled. A
    job can be cancelled only if it has not yet started executing.
    
    Success response indicates only that the request was received. Cancellation is not guaranteed,
    as it is based on job state at the time of cancellation, and is completed on a best effort
    basis.
    
    :param job_id: The job ID to cancel.
    :param quantum_processor_id: The quantum processor to execute the job on. This parameter is required unless using the ``ConnectionStrategy.endpoint_id()`` or ``ConnectionStrategy.endpoint_address()`` execution option.
    :param client: The ``Qcs`` client to use.
    :param execution_options: The ``ExecutionOptions`` to use.
    """

def cancel_job_async(job_id: builtins.str, quantum_processor_id: typing.Optional[builtins.str] = None, client: typing.Optional[QCSClient] = None, execution_options: typing.Optional[ExecutionOptions] = None) -> collections.abc.Awaitable[None]:
    r"""
    Cancel a job that has yet to begin executing.
    
    This action is *not* atomic, and will attempt to cancel a job even if it cannot be cancelled. A
    job can be cancelled only if it has not yet started executing.
    
    Success response indicates only that the request was received. Cancellation is not guaranteed,
    as it is based on job state at the time of cancellation, and is completed on a best effort
    basis.
    
    :param job_id: The job ID to cancel.
    :param quantum_processor_id: The quantum processor to execute the job on. This parameter is required unless using the ``ConnectionStrategy.endpoint_id()`` or ``ConnectionStrategy.endpoint_address()`` execution option.
    :param client: The ``Qcs`` client to use.
    :param execution_options: The ``ExecutionOptions`` to use.
    """

def cancel_jobs(job_ids: typing.Sequence[builtins.str], quantum_processor_id: typing.Optional[builtins.str] = None, client: typing.Optional[QCSClient] = None, execution_options: typing.Optional[ExecutionOptions] = None) -> None:
    r"""
    Cancel all given jobs that have yet to begin executing.
    
    This action is *not* atomic, and will attempt to cancel every job even when some jobs cannot be
    cancelled. A job can be cancelled only if it has not yet started executing.
    
    Success response indicates only that the request was received. Cancellation is not guaranteed,
    as it is based on job state at the time of cancellation, and is completed on a best effort
    basis.
    
    :param job_ids: The job IDs to cancel.
    :param quantum_processor_id: The quantum processor to execute the job on. This parameter is required unless using the ``ConnectionStrategy.endpoint_id()`` or ``ConnectionStrategy.endpoint_address()`` execution option.
    :param client: The ``Qcs`` client to use.
    :param execution_options: The ``ExecutionOptions`` to use.
    """

def cancel_jobs_async(job_ids: typing.Sequence[builtins.str], quantum_processor_id: typing.Optional[builtins.str] = None, client: typing.Optional[QCSClient] = None, execution_options: typing.Optional[ExecutionOptions] = None) -> collections.abc.Awaitable[None]:
    r"""
    Cancel all given jobs that have yet to begin executing.
    
    This action is *not* atomic, and will attempt to cancel every job even when some jobs cannot be
    cancelled. A job can be cancelled only if it has not yet started executing.
    
    Success response indicates only that the request was received. Cancellation is not guaranteed,
    as it is based on job state at the time of cancellation, and is completed on a best effort
    basis.
    
    :param job_ids: The job IDs to cancel.
    :param quantum_processor_id: The quantum processor to execute the job on. This parameter is required unless using the ``ConnectionStrategy.endpoint_id()`` or ``ConnectionStrategy.endpoint_address()`` execution option.
    :param client: The ``Qcs`` client to use.
    :param execution_options: The ``ExecutionOptions`` to use.
    """

def retrieve_results(job_id: builtins.str, quantum_processor_id: typing.Optional[builtins.str] = None, client: typing.Optional[QCSClient] = None, execution_options: typing.Optional[ExecutionOptions] = None) -> ExecutionResults:
    r"""
    Fetches execution results for the given QCS Job ID.
    
    :param job_id: The ID of the job to retrieve results for.
    :param quantum_processor_id: The ID of the quantum processor the job ran on. This field is required, unless being used with the ``ConnectionStrategy.endpoint_id()`` or ``ConnectionStrategy.endpoint_address()`` execution option.
    :param client: The ``Qcs`` client to use. Creates one using environment configuration if unset - see https://docs.rigetti.com/qcs/references/qcs-client-configuration
    :param execution_options: The ``ExecutionOptions`` to use.
    
    :returns: Results from execution.
    
    :raises LoadClientError: If there is an issue loading the QCS Client configuration.
    :raises QpuApiError: If there was a problem retrieving the results.
    """

def retrieve_results_async(job_id: builtins.str, quantum_processor_id: typing.Optional[builtins.str] = None, client: typing.Optional[QCSClient] = None, execution_options: typing.Optional[ExecutionOptions] = None) -> collections.abc.Awaitable[ExecutionResults]:
    r"""
    Fetches execution results for the given QCS Job ID.
    
    :param job_id: The ID of the job to retrieve results for.
    :param quantum_processor_id: The ID of the quantum processor the job ran on. This field is required, unless being used with the ``ConnectionStrategy.endpoint_id()`` or ``ConnectionStrategy.endpoint_address()`` execution option.
    :param client: The ``Qcs`` client to use. Creates one using environment configuration if unset - see https://docs.rigetti.com/qcs/references/qcs-client-configuration
    :param execution_options: The ``ExecutionOptions`` to use.
    
    :returns: Results from execution.
    
    :raises LoadClientError: If there is an issue loading the QCS Client configuration.
    :raises QpuApiError: If there was a problem retrieving the results.
    """

def submit(program: builtins.str, patch_values: typing.Mapping[builtins.str, typing.Sequence[builtins.float]], quantum_processor_id: typing.Optional[builtins.str] = None, client: typing.Optional[QCSClient] = None, execution_options: typing.Optional[ExecutionOptions] = None) -> builtins.str:
    r"""
    Submits an executable `program` to be run on the specified QPU.
    
    :param program: An executable program (see ``qcs_sdk.qpu.translation.translate``).
    :param patch_values: A mapping of symbols to their desired values (see ``build_patch_values``).
    :param quantum_processor_id: The ID of the quantum processor to run the executable on.
        This field is required, unless being used with the ``ConnectionStrategy.endpoint_id()``
        or ``ConnectionStrategy.endpoint_address()`` execution option.
    :param client: The ``Qcs`` client to use.
        Creates one using environment configuration if unset.
        See https://docs.rigetti.com/qcs/references/qcs-client-configuration for more information.
    :param execution_options: The ``ExecutionOptions`` to use.
        If the connection strategy option used is ``ConnectionStrategy.endpoint_id("endpoint_id")``
        or ``ConnectionStrategy.endpoint_address("http://some_endpoint_address")``,
        then direct access to "endpoint_id" overrides the ``quantum_processor_id`` parameter.
    
    :returns: The ID of the submitted job which can be used to fetch results.
    
    :raises LoadClientError: If there is an issue loading the QCS Client configuration.
    :raises SubmissionError: If there was a problem submitting the program for execution.
    """

def submit_async(program: builtins.str, patch_values: typing.Mapping[builtins.str, typing.Sequence[builtins.float]], quantum_processor_id: typing.Optional[builtins.str] = None, client: typing.Optional[QCSClient] = None, execution_options: typing.Optional[ExecutionOptions] = None) -> collections.abc.Awaitable[builtins.str]:
    r"""
    Submits an executable `program` to be run on the specified QPU.
    
    :param program: An executable program (see ``qcs_sdk.qpu.translation.translate``).
    :param patch_values: A mapping of symbols to their desired values (see ``build_patch_values``).
    :param quantum_processor_id: The ID of the quantum processor to run the executable on.
        This field is required, unless being used with the ``ConnectionStrategy.endpoint_id()``
        or ``ConnectionStrategy.endpoint_address()`` execution option.
    :param client: The ``Qcs`` client to use.
        Creates one using environment configuration if unset.
        See https://docs.rigetti.com/qcs/references/qcs-client-configuration for more information.
    :param execution_options: The ``ExecutionOptions`` to use.
        If the connection strategy option used is ``ConnectionStrategy.endpoint_id("endpoint_id")``
        or ``ConnectionStrategy.endpoint_address("http://some_endpoint_address")``,
        then direct access to "endpoint_id" overrides the ``quantum_processor_id`` parameter.
    
    :returns: The ID of the submitted job which can be used to fetch results.
    
    :raises LoadClientError: If there is an issue loading the QCS Client configuration.
    :raises SubmissionError: If there was a problem submitting the program for execution.
    """

def submit_with_parameter_batch(program: builtins.str, patch_values: typing.Sequence[typing.Mapping[builtins.str, typing.Sequence[builtins.float]]], quantum_processor_id: typing.Optional[builtins.str] = None, client: typing.Optional[QCSClient] = None, execution_options: typing.Optional[ExecutionOptions] = None) -> builtins.list[builtins.str]:
    r"""
    Execute a compiled program on a QPU with multiple sets of ``patch_values``.
    
    This action is *atomic* in that all jobs will be queued, or none of them will. On success, this
    function will return a list of strings where the length and order correspond to the
    ``patch_values`` given. However, note that execution in the order of given patch values is not
    guaranteed. If there is a failure to queue any of the jobs, then none will be queued.
    
    :param program: An executable program (see ``translate``).
    :param patch_values: An iterable containing one or more mapping of symbols to their desired values.
    :param quantum_processor_id: The ID of the quantum processor to run the executable on. This field is required, unless being used with the ``ConnectionStrategy.endpoint_id()`` or ``ConnectionStrategy.endpoint_address()`` execution option.
    :param client: The ``Qcs`` client to use. Creates one using environment configuration if unset - see https://docs.rigetti.com/qcs/references/qcs-client-configuration
    :param execution_options: The ``ExecutionOptions`` to use.
    
    :returns: The IDs of the submitted jobs which can be used to fetch results.
    
    :raises LoadClientError: If there is an issue loading the QCS Client configuration.
    :raises SubmissionError: If there was a problem submitting any of the jobs for execution, or if no ``patch_values`` are given.
    """

def submit_with_parameter_batch_async(program: builtins.str, patch_values: typing.Sequence[typing.Mapping[builtins.str, typing.Sequence[builtins.float]]], quantum_processor_id: typing.Optional[builtins.str] = None, client: typing.Optional[QCSClient] = None, execution_options: typing.Optional[ExecutionOptions] = None) -> collections.abc.Awaitable[builtins.list[builtins.str]]:
    r"""
    Execute a compiled program on a QPU with multiple sets of ``patch_values``.
    
    This action is *atomic* in that all jobs will be queued, or none of them will. On success, this
    function will return a list of strings where the length and order correspond to the
    ``patch_values`` given. However, note that execution in the order of given patch values is not
    guaranteed. If there is a failure to queue any of the jobs, then none will be queued.
    
    :param program: An executable program (see ``translate``).
    :param patch_values: An iterable containing one or more mapping of symbols to their desired values.
    :param quantum_processor_id: The ID of the quantum processor to run the executable on. This field is required, unless being used with the ``ConnectionStrategy.endpoint_id()`` or ``ConnectionStrategy.endpoint_address()`` execution option.
    :param client: The ``Qcs`` client to use. Creates one using environment configuration if unset - see https://docs.rigetti.com/qcs/references/qcs-client-configuration
    :param execution_options: The ``ExecutionOptions`` to use.
    
    :returns: The IDs of the submitted jobs which can be used to fetch results.
    
    :raises LoadClientError: If there is an issue loading the QCS Client configuration.
    :raises SubmissionError: If there was a problem submitting any of the jobs for execution, or if no ``patch_values`` are given.
    """