File: messages.py

package info (click to toggle)
python-rpcq 3.11.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300 kB
  • sloc: python: 1,525; makefile: 3
file content (423 lines) | stat: -rw-r--r-- 10,856 bytes parent folder | download
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
#!/usr/bin/env python

"""
WARNING: This file is auto-generated, do not edit by hand. See README.md.
"""

import sys

from warnings import warn
from rpcq._base import Message
from typing import Any, List, Dict, Optional

if sys.version_info < (3, 7):
    from rpcq.external.dataclasses import dataclass, field, InitVar
else:
    from dataclasses import dataclass, field, InitVar


@dataclass(eq=False, repr=False)
class ParameterSpec(Message):
    """
    Specification of a dynamic parameter type and array-length.
    """

    type: str = ""
    """The parameter type, e.g., one of 'INTEGER', or 'FLOAT'."""

    length: int = 1
    """If this is not 1, the parameter is an array of this length."""


@dataclass(eq=False, repr=False)
class ParameterAref(Message):
    """
    A parametric expression.
    """

    name: str
    """The parameter name"""

    index: int
    """The array index."""


@dataclass(eq=False, repr=False)
class PatchTarget(Message):
    """
    Patchable memory location descriptor.
    """

    patch_type: ParameterSpec
    """Data type at this address."""

    patch_offset: int
    """Memory address of the patch."""


@dataclass(eq=False, repr=False)
class RPCRequest(Message):
    """
    A single request object according to the JSONRPC standard.
    """

    method: str
    """The RPC function name."""

    params: Any
    """The RPC function arguments."""

    id: str
    """RPC request id (used to verify that request and response belong together)."""

    jsonrpc: str = "2.0"
    """The JSONRPC version."""

    client_timeout: Optional[float] = None
    """The client-side timeout for the request. The server itself may be configured with a timeout that is greater than the client-side timeout, in which case the server can choose to terminate any processing of the request."""

    client_key: Optional[str] = None
    """The ZeroMQ CURVE public key used to make the request, as received by the server. Empty if no key is used."""


@dataclass(eq=False, repr=False)
class RPCWarning(Message):
    """
    An individual warning emitted in the course of RPC processing.
    """

    body: str
    """The warning string."""

    kind: Optional[str] = None
    """The type of the warning raised."""


@dataclass(eq=False, repr=False)
class RPCReply(Message):
    """
    The reply for a JSONRPC request.
    """

    id: str
    """The RPC request id."""

    jsonrpc: str = "2.0"
    """The JSONRPC version."""

    result: Optional[Any] = None
    """The RPC result."""

    warnings: List[RPCWarning] = field(default_factory=list)
    """A list of warnings that occurred during request processing."""


@dataclass(eq=False, repr=False)
class RPCError(Message):
    """
    A error message for JSONRPC requests.
    """

    error: str
    """The error message."""

    id: str
    """The RPC request id."""

    jsonrpc: str = "2.0"
    """The JSONRPC version."""

    warnings: List[RPCWarning] = field(default_factory=list)
    """A list of warnings that occurred during request processing."""


@dataclass(eq=False, repr=False)
class TargetDevice(Message):
    """
    ISA and specs for a particular device.
    """

    isa: Dict[str, Dict]
    """Instruction-set architecture for this device."""

    specs: Dict[str, Dict]
    """Fidelities and coherence times for this device."""


@dataclass(eq=False, repr=False)
class RandomizedBenchmarkingRequest(Message):
    """
    RPC request payload for generating a randomized benchmarking sequence.
    """

    depth: int
    """Depth of the benchmarking sequence."""

    qubits: int
    """Number of qubits involved in the benchmarking sequence."""

    gateset: List[str]
    """List of Quil programs, each describing a Clifford."""

    seed: Optional[int] = None
    """PRNG seed. Set this to guarantee repeatable results."""

    interleaver: Optional[str] = None
    """Fixed Clifford, specified as a Quil string, to interleave through an RB sequence."""


@dataclass(eq=False, repr=False)
class RandomizedBenchmarkingResponse(Message):
    """
    RPC reply payload for a randomly generated benchmarking sequence.
    """

    sequence: List[List[int]]
    """List of Cliffords, each expressed as a list of generator indices."""


@dataclass(eq=False, repr=False)
class PauliTerm(Message):
    """
    Specification of a single Pauli term as a tensor product of Pauli factors.
    """

    indices: List[int]
    """Qubit indices onto which the factors of a Pauli term are applied."""

    symbols: List[str]
    """Ordered factors of a Pauli term."""


@dataclass(eq=False, repr=False)
class ConjugateByCliffordRequest(Message):
    """
    RPC request payload for conjugating a Pauli element by a Clifford element.
    """

    pauli: PauliTerm
    """Specification of a Pauli element."""

    clifford: str
    """Specification of a Clifford element."""


@dataclass(eq=False, repr=False)
class ConjugateByCliffordResponse(Message):
    """
    RPC reply payload for a Pauli element as conjugated by a Clifford element.
    """

    phase: int
    """Encoded global phase factor on the emitted Pauli."""

    pauli: str
    """Description of the encoded Pauli."""


@dataclass(eq=False, repr=False)
class NativeQuilRequest(Message):
    """
    Quil and the device metadata necessary for quilc.
    """

    quil: str
    """Arbitrary Quil to be sent to quilc."""

    target_device: TargetDevice
    """Specifications for the device to target with quilc."""


@dataclass(eq=False, repr=False)
class NativeQuilMetadata(Message):
    """
    Metadata for a native quil program.
    """

    final_rewiring: List[int] = field(default_factory=list)
    """Output qubit index relabeling due to SWAP insertion."""

    gate_depth: Optional[int] = None
    """Maximum number of successive gates in the native quil program."""

    gate_volume: Optional[int] = None
    """Total number of gates in the native quil program."""

    multiqubit_gate_depth: Optional[int] = None
    """Maximum number of successive two-qubit gates in the native quil program."""

    program_duration: Optional[float] = None
    """Rough estimate of native quil program length in nanoseconds."""

    program_fidelity: Optional[float] = None
    """Rough estimate of the fidelity of the full native quil program, uses specs."""

    topological_swaps: Optional[int] = None
    """Total number of SWAPs in the native quil program."""

    qpu_runtime_estimation: Optional[float] = None
    """The estimated runtime (milliseconds) on a Rigetti QPU for a protoquil program."""


@dataclass(eq=False, repr=False)
class NativeQuilResponse(Message):
    """
    Native Quil and associated metadata returned from quilc.
    """

    quil: str
    """Native Quil returned from quilc."""

    metadata: Optional[NativeQuilMetadata] = None
    """Metadata for the returned Native Quil."""


@dataclass(eq=False, repr=False)
class RewriteArithmeticRequest(Message):
    """
    A request type to handle compiling arithmetic out of gate parameters.
    """

    quil: str
    """Native Quil for which to rewrite arithmetic parameters."""


@dataclass(eq=False, repr=False)
class RewriteArithmeticResponse(Message):
    """
    The data needed to run programs with gate arithmetic on the hardware.
    """

    quil: str
    """Native Quil rewritten with no arithmetic in gate parameters."""

    original_memory_descriptors: Dict[str, ParameterSpec] = field(default_factory=dict)
    """The declared memory descriptors in the Quil of the related request."""

    recalculation_table: Dict[ParameterAref, str] = field(default_factory=dict)
    """A mapping from memory references to the original gate arithmetic."""


@dataclass(eq=False, repr=False)
class BinaryExecutableRequest(Message):
    """
    Native Quil and the information needed to create binary executables.
    """

    quil: str
    """Native Quil to be translated into an executable program."""

    num_shots: int
    """The number of times to repeat the program."""


@dataclass(eq=False, repr=False)
class BinaryExecutableResponse(Message):
    """
    Program to run on the QPU.
    """

    program: str
    """Execution settings and sequencer binaries."""

    memory_descriptors: Dict[str, ParameterSpec] = field(default_factory=dict)
    """Internal field for constructing patch tables."""

    ro_sources: List[Any] = field(default_factory=list)
    """Internal field for reshaping returned buffers."""


@dataclass(eq=False, repr=False)
class QuiltBinaryExecutableRequest(Message):
    """
    Native Quilt and the information needed to create binary executables.
    """

    quilt: str
    """Native Quilt to be translated into an executable program."""

    num_shots: int
    """The number of times to repeat the program."""


@dataclass(eq=False, repr=False)
class QuiltBinaryExecutableResponse(Message):
    """
    Program to run on the QPU.
    """

    program: str
    """Execution settings and sequencer binaries."""

    debug: Dict[str, Any]
    """Debug information associated with the translation process."""

    memory_descriptors: Dict[str, ParameterSpec] = field(default_factory=dict)
    """Internal field for constructing patch tables."""

    ro_sources: List[Any] = field(default_factory=list)
    """Internal field for reshaping returned buffers."""


@dataclass(eq=False, repr=False)
class PyQuilExecutableResponse(Message):
    """
    rpcQ-serializable form of a pyQuil Program object.
    """

    program: str
    """String representation of a Quil program."""

    attributes: Dict[str, Any]
    """Miscellaneous attributes to be unpacked onto the pyQuil Program object."""


@dataclass(eq=False, repr=False)
class QPURequest(Message):
    """
    Program and patch values to send to the QPU for execution.
    """

    program: Any
    """Execution settings and sequencer binaries."""

    patch_values: Dict[str, List[Any]]
    """Dictionary mapping data names to data values for patching the binary."""

    id: str
    """QPU request ID."""


@dataclass(eq=False, repr=False)
class QuiltCalibrationsRequest(Message):
    """
    A request for up-to-date Quilt calibrations.
    """

    target_device: TargetDevice
    """Specifications for the device to get calibrations for."""


@dataclass(eq=False, repr=False)
class QuiltCalibrationsResponse(Message):
    """
    Up-to-date Quilt calibrations.
    """

    quilt: str
    """Quilt code with definitions for frames, waveforms, and calibrations."""


@dataclass(eq=False, repr=False)
class GetExecutionResultsResponse(Message):
    """
    Results of a completed ExecutorJob execution.
    """

    buffers: Dict[str, Dict[str, Any]]
    """Result buffers for a completed ExecutorJob."""

    execution_duration_microseconds: int
    """Duration (in microseconds) ExecutorJob held exclusive access to quantum hardware."""