Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add standardized device calibration data for OQC and Rigetti #109

Merged
merged 30 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e721c72
feature: Add PeristedJobData schema (#1)
kshitijc Sep 13, 2021
6ffc1f2
sync: public changes to staging (#3)
virajvchaudhari Sep 14, 2021
43c8a02
Sync with public repository (#10)
kshitijc Jan 12, 2022
b86ab27
Merge openqasm changes to main (#11)
kshitijc Jan 12, 2022
b449437
sync: public schemas to staging (#15)
virajvchaudhari Jan 28, 2022
0e46a0c
feature: add ECR gate (#14)
virajvchaudhari Feb 1, 2022
bc69ee9
sync: public changes to staging (#17)
virajvchaudhari Feb 2, 2022
43f90b3
fix: loosen Enum type restrictions to strings (#18)
virajvchaudhari Feb 3, 2022
9469aaf
feature: add schemas for OQC (#12)
virajvchaudhari Feb 7, 2022
9300b13
feat: Add OQC executedProgram in task result metadata (#20)
kshitijc Feb 11, 2022
12b80ab
fix: correct provider properties field for OQC
Feb 10, 2022
be89d85
fix: correct provider properties field for OQC
saravsak Feb 16, 2022
3f17876
fix: added OQC device parameter to TaskMetadata
Feb 18, 2022
4f733c9
Merge pull request #21 from aws/result
rchilaka-amzn Feb 18, 2022
82c49cf
fix: Rename executedProgram to compiledProgram
kshitijc Feb 25, 2022
01b1b10
Revert "fix: Rename executedProgram to compiledProgram"
rchilaka-amzn Feb 25, 2022
508eeae
Add supportsPartialVerbatimBox, supportsUnassignedMeasurements to Ope…
rchilaka-amzn Feb 25, 2022
3f4e019
fix: Rename executedProgram to compiledProgram
kshitijc Feb 25, 2022
8599541
fix: make provider properties specs to keep consistent with similar p…
Mar 17, 2022
35fd178
Merge pull request #25 from aws/oqc-minor-fix
MattCordoba Mar 18, 2022
69fb3b4
fix: Update type hint for specs object to reflect new structure
Mar 21, 2022
8ed8fb7
Merge pull request #26 from aws/oqc-fix-type-hint
MattCordoba Mar 21, 2022
26f8082
Revert "Merge pull request #26 from aws/oqc-fix-type-hint"
Mar 23, 2022
1319d8d
Revert "fix: make provider properties specs to keep consistent with s…
Mar 23, 2022
b79c33c
fix: Update OQC json schema to match GetDevice API call
Mar 23, 2022
8e91be6
Merge pull request #28 from aws/match-json-schema-oqc
MattCordoba Mar 28, 2022
5f2cf38
feat: Add standardized device calibration data for OQC and Rigetti (#29)
MattCordoba Mar 31, 2022
5460304
feat: Add standardized device calibration data for OQC and Rigetti
Mar 31, 2022
0782fd9
feat: Add standardized device calibration data for OQC and Rigetti
Mar 31, 2022
6ea8223
feat: Add standardized device calibration data for OQC and Rigetti
Mar 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/braket/device_schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@
from braket.device_schema.openqasm_device_action_properties import ( # noqa: F401
OpenQASMDeviceActionProperties,
)
from braket.device_schema.standardized_gate_model_qpu_device_properties_v1 import ( # noqa: F401
StandardizedGateModelQpuDeviceProperties,
)
9 changes: 9 additions & 0 deletions src/braket/device_schema/oqc/oqc_device_capabilities_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
from braket.device_schema.jaqcd_device_action_properties import JaqcdDeviceActionProperties
from braket.device_schema.openqasm_device_action_properties import OpenQASMDeviceActionProperties
from braket.device_schema.oqc.oqc_provider_properties_v1 import OqcProviderProperties
from braket.device_schema.standardized_gate_model_qpu_device_properties_v1 import (
StandardizedGateModelQpuDeviceProperties,
)
from braket.schema_common import BraketSchemaBase, BraketSchemaHeader

# TODO: Update the device and topology details when we have information from the provider
Expand All @@ -38,6 +41,9 @@ class OqcDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
OQC device can support
paradigm(GateModelQpuParadigmProperties): Paradigm properties
provider(Optional[OqcProviderProperties]): OQC provider specific properties
standardized
(StandardizedGateModelQpuDeviceProperties): Braket standarized device
properties for OQC

Examples:
>>> import json
Expand Down Expand Up @@ -97,6 +103,8 @@ class OqcDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
... },
... },
... "deviceParameters": {OqcDeviceParameters.schema_json()},
... "standardized": \
... {StandardizedGateModelQpuDeviceProperties.schema_json()},,
... }
>>> OqcDeviceCapabilities.parse_raw_schema(json.dumps(input_json))
"""
Expand All @@ -111,3 +119,4 @@ class OqcDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
]
paradigm: GateModelQpuParadigmProperties
provider: Optional[OqcProviderProperties]
standardized: Optional[StandardizedGateModelQpuDeviceProperties]
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
from braket.device_schema.jaqcd_device_action_properties import JaqcdDeviceActionProperties
from braket.device_schema.openqasm_device_action_properties import OpenQASMDeviceActionProperties
from braket.device_schema.rigetti.rigetti_provider_properties_v1 import RigettiProviderProperties
from braket.device_schema.standardized_gate_model_qpu_device_properties_v1 import (
StandardizedGateModelQpuDeviceProperties,
)
from braket.schema_common import BraketSchemaBase, BraketSchemaHeader


Expand All @@ -36,6 +39,9 @@ class RigettiDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
Rigetti device can support
paradigm(GateModelQpuParadigmProperties): Paradigm properties of a Rigetti
provider(Optional[RigettiProviderProperties]): Rigetti provider specific properties
standardized
(StandardizedGateModelQpuDeviceProperties): Braket standarized device
properties for Rigetti

Examples:
>>> import json
Expand Down Expand Up @@ -95,6 +101,8 @@ class RigettiDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
... },
... },
... "deviceParameters": {RigettiDeviceParameters.schema_json()},
... "standardized": \
... {StandardizedGateModelQpuDeviceProperties.schema_json()},
... }
>>> RigettiDeviceCapabilities.parse_raw_schema(json.dumps(input_json))

Expand All @@ -110,3 +118,4 @@ class RigettiDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
]
paradigm: GateModelQpuParadigmProperties
provider: Optional[RigettiProviderProperties]
standardized: Optional[StandardizedGateModelQpuDeviceProperties]
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

from enum import Enum
from typing import Dict, List, Optional

from pydantic import BaseModel, Field, confloat

from braket.schema_common import BraketSchemaBase, BraketSchemaHeader


class QubitDirection(str, Enum):
"""
Enum for qubit direction labels for two-qubit fidelity details
"""

CONTROL = "control"
TARGET = "target"


class FidelityType(BaseModel):
"""
Fidelity measurement types
Attributes:
name (str): description of the fidelity measurement
description (Optional[str]): Optional description for how the fidelity
measurement was performed
"""

name: str
description: Optional[str]


class GateFidelity2Q(BaseModel):
"""
Describes the fidelity of two-qubit pairing
Attributes:
direction (Optional[Dict[QubitDirection, int]]): Describes which qubit is
control/target for the pair. If direction is None the pair is considered
bi-directional.
gateName (str): the 2-qubit gate that the fidelity measurement was performed on
fidelity (float): the fidelity value
standardError (Optional[float]): Describes the error value on the fidelity measurement
fidelityType (FidelityType): The fidelity measurement technique used
for the presented value
"""

direction: Optional[Dict[QubitDirection, int]] = None
gateName: str
fidelity: confloat(ge=0, le=1)
standardError: Optional[confloat(ge=0, le=1)] = None
fidelityType: FidelityType


class TwoQubitProperties(BaseModel):
"""
The standard two-qubit calibration details for a quantum hardware provider
Attributes:
twoQubitGateFidelity: two qubit fidelity properties
"""

twoQubitGateFidelity: List[GateFidelity2Q]


class Fidelity1Q(BaseModel):
"""
Describes one qubit fidelity measured on a qubit
Attributes:
fidelityType (FidelityType): The fidelity measurement technique used
for the presented value
fidelity (float): The measured fidelity value
standardError (Optional[float]) The expected error value reported
on the measurement
"""

fidelityType: FidelityType
fidelity: confloat(ge=0, le=1)
standardError: Optional[confloat(ge=0, le=1)] = None


class CoherenceTime(BaseModel):
"""
The coherence time values provided for the device
Attributes:
value (str): The coherence time value
standardError (str): The error/confidence in coherence measurement provided
unit (str): The unit for the described value
"""

value: float
standardError: Optional[float]
unit: str


class OneQubitProperties(BaseModel):
"""
The standard one-qubit calibration details for a quantum hardware provider
Attributes:
T1: The T1 decoherence/relaxation time data structure
T2: The T2 coherence/dephasing time
oneQubitFidelity: one qubit fidelity properties
"""

T1: CoherenceTime
T2: CoherenceTime
oneQubitFidelity: List[Fidelity1Q]


class StandardizedGateModelQpuDeviceProperties(BraketSchemaBase):
"""

Braket standarized gate model device qpu properties for the given quantum hardware

Attributes:
oneQubitProperties (Dict[str, OneQubitProperties]): Dictionary describing a qubit
identifier (ex: '1'), to the calibration property set
twoQubitProperties (Dict[str, TwoQubitProperties]): Dictionary describing the
two-qubit identifier (ex: '0-1'), to the calibration property set
Examples:
>>> import json
>>> valid_input = {
... "braketSchemaHeader": {
... "name": \
... "braket.device_schema.standardized_gate_model_qpu_device_properties",
... "version": "1",
... },
... "oneQubitProperties": {
... "0": {
... "T1": {"value": 28.9, "standardError": 0.01, "unit": "us"},
... "T2": {"value": 44.5, "standardError": 0.02, "unit": "us"},
... "oneQubitFidelity": [
... {
... "fidelityType": {
... "name": "RANDOMIZED_BENCHMARKING",
... "description": "uses a standard RB technique",
... },
... "fidelity": 0.9993,
... },
... {
... "fidelityType": {"name": "READOUT"},
... "fidelity": 0.903,
... "standardError": None,
... },
... ],
... },
... "1": {
... "T1": {"value": 28.9, "unit": "us"},
... "T2": {"value": 44.5, "standardError": 0.02, "unit": "us"},
... "oneQubitFidelity": [
... {
... "fidelityType": {"name": "RANDOMIZED_BENCHMARKING"},
... "fidelity": 0.9986,
... "standardError": None,
... },
... {
... "fidelityType": {"name": "READOUT"},
... "fidelity": 0.867,
... "standardError": None,
... },
... ],
... },
... },
... "twoQubitProperties": {
... "0-1": {
... "twoQubitGateFidelity": [
... {
... "direction": {"control": 0, "target": 1},
... "gateName": "CNOT",
... "fidelity": 0.877,
... "fidelityType": {"name": "INTERLEAVED_RANDOMIZED_BENCHMARKING"},
... }
... ]
... },
... "0-7": {
... "twoQubitGateFidelity": [
... {
... "direction": {"control": 0, "target": 7},
... "gateName": "CNOT",
... "fidelity": 0.877,
... "standardError": 0.001,
... "fidelityType": {"name": "INTERLEAVED_RANDOMIZED_BENCHMARKING"},
... }
... ]
... },
... },
... }
>>> StandardizedGateModelQpuDeviceProperties.parse_raw_schema(json.dumps(valid_input))
"""

_PROGRAM_HEADER = BraketSchemaHeader(
name="braket.device_schema.standardized_gate_model_qpu_device_properties", version="1"
)
braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
oneQubitProperties: Dict[str, OneQubitProperties]
twoQubitProperties: Dict[str, TwoQubitProperties]
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,43 @@

from braket.device_schema.oqc.oqc_device_capabilities_v1 import OqcDeviceCapabilities

device_properties_data = {
"braketSchemaHeader": {
"name": "braket.device_schema.standardized_gate_model_qpu_device_properties",
"version": "1",
},
"oneQubitProperties": {
"0": {
"T1": {"value": 28.9, "standardError": 0.01, "unit": "us"},
"T2": {"value": 44.5, "standardError": 0.02, "unit": "us"},
"oneQubitFidelity": [
{
"fidelityType": {"name": "READOUT"},
"fidelity": 0.9993,
"standardError": None,
},
{
"fidelityType": {"name": "RANDOMIZED_BENCHMARKING"},
"fidelity": 0.903,
"standardError": None,
},
],
}
},
"twoQubitProperties": {
"0-1": {
"twoQubitGateFidelity": [
{
"direction": {"control": 0, "target": 1},
"gateName": "CNOT",
"fidelity": 0.877,
"fidelityType": {"name": "INTERLEAVED_RANDOMIZED_BENCHMARKING"},
}
]
}
},
}

jaqcd_valid_input = {
"braketSchemaHeader": {
"name": "braket.device_schema.oqc.oqc_device_capabilities",
Expand Down Expand Up @@ -124,6 +161,7 @@
"connectivity": {"fullyConnected": False, "connectivityGraph": {"1": ["2", "3"]}},
},
"deviceParameters": {},
"standardized": device_properties_data,
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,43 @@

from braket.device_schema.rigetti.rigetti_device_capabilities_v1 import RigettiDeviceCapabilities

device_properties_data = {
"braketSchemaHeader": {
"name": "braket.device_schema.standardized_gate_model_qpu_device_properties",
"version": "1",
},
"oneQubitProperties": {
"0": {
"T1": {"value": 28.9, "standardError": 0.01, "unit": "us"},
"T2": {"value": 44.5, "standardError": 0.02, "unit": "us"},
"oneQubitFidelity": [
{
"fidelityType": {"name": "READOUT"},
"fidelity": 0.9993,
"standardError": None,
},
{
"fidelityType": {"name": "RANDOMIZED_BENCHMARKING"},
"fidelity": 0.903,
"standardError": None,
},
],
}
},
"twoQubitProperties": {
"0-1": {
"twoQubitGateFidelity": [
{
"direction": {"control": 0, "target": 1},
"gateName": "CNOT",
"fidelity": 0.877,
"fidelityType": {"name": "INTERLEAVED_RANDOMIZED_BENCHMARKING"},
}
]
}
},
}

jaqcd_valid_input = {
"braketSchemaHeader": {
"name": "braket.device_schema.rigetti.rigetti_device_capabilities",
Expand Down Expand Up @@ -66,6 +103,7 @@
"connectivity": {"fullyConnected": False, "connectivityGraph": {"1": ["2", "3"]}},
},
"deviceParameters": {},
"standardized": device_properties_data,
}


Expand Down