Coverage for src/braket/task_result/rigetti_metadata_v1.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"). You
4# may not use this file except in compliance with the License. A copy of
5# the License is located at
6#
7# http://aws.amazon.com/apache2.0/
8#
9# or in the "license" file accompanying this file. This file is
10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11# ANY KIND, either express or implied. See the License for the specific
12# language governing permissions and limitations under the License
14from typing import Optional
16from pydantic import BaseModel, Field, confloat, conint, conlist, constr
18from braket.schema_common import BraketSchemaBase, BraketSchemaHeader
21class NativeQuilMetadata(BaseModel):
22 """
23 Schema to hold native quil metadata returned by
24 Rigetti after compilation.
26 Examples:
27 >>> NativeQuilMetadata(finalRewiring=[32,21],
28 gateDepth=5,
29 gateVolume=6,
30 multiQubitGateDepth=1,
31 programDuration=300.1,
32 programFidelity=0.8989,
33 qpuRuntimeEstimation=191.21,
34 topologicalSwaps=0)
35 """
37 finalRewiring: conlist(int)
38 gateDepth: conint(ge=0)
39 gateVolume: conint(ge=0)
40 multiQubitGateDepth: conint(ge=0)
41 programDuration: confloat(gt=0)
42 programFidelity: confloat(gt=0)
43 qpuRuntimeEstimation: confloat(gt=0)
44 topologicalSwaps: conint(ge=0)
47class RigettiMetadata(BraketSchemaBase):
48 """
49 The Rigetti metadata result schema.
51 Attributes:
52 braketSchemaHeader (BraketSchemaHeader): Schema header.
53 Users do not need to set this value. Only default is allowed.
54 nativeQuilMetadata (NativeQuilMetadata)
55 program (str): The compiled program executed on the QPU
57 Examples:
58 >>> quil_metadata = NativeQuilMetadata(finalRewiring=[32,21],
59 gateDepth=5,
60 gateVolume=6,
61 multiQubitGateDepth=1,
62 programDuration=300.1,
63 programFidelity=0.8989,
64 qpuRuntimeEstimation=191.21,
65 topologicalSwaps=0)
66 >>> RigettiMetadata(program="DECLARE ro BIT[2]", nativeQuilMetadata=quil_metadata)
69 """
71 _RIGETTI_METADATA_HEADER = BraketSchemaHeader(
72 name="braket.task_result.rigetti_metadata", version="1"
73 )
74 braketSchemaHeader: BraketSchemaHeader = Field(
75 default=_RIGETTI_METADATA_HEADER, const=_RIGETTI_METADATA_HEADER
76 )
78 nativeQuilMetadata: Optional[NativeQuilMetadata]
79 compiledProgram: constr(min_length=2)