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

Adding Device Documentation Properties #25

Merged
merged 6 commits into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/braket/device_schema/device_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from pydantic import BaseModel

from braket.device_schema.device_action_properties import DeviceActionProperties, DeviceActionType
from braket.device_schema.device_level_properties import DeviceLevelProperties
from braket.device_schema.device_service_properties_v1 import DeviceServiceProperties


Expand Down Expand Up @@ -54,11 +55,20 @@ class DeviceCapabilities(BaseModel):
... "version": ["1.0", "1.1"],
... }
... },
... "deviceParameters": {#Schema of specific device parameter instance}
... "deviceParameters": {#Schema of specific device parameter instance},
... "device" : {
kalhanreddy marked this conversation as resolved.
Show resolved Hide resolved
... "supportedRegions": ["IAD"],
kalhanreddy marked this conversation as resolved.
Show resolved Hide resolved
... "deviceCost": [10, "task"],
... "deviceMetadata": "metadata of the device",
kalhanreddy marked this conversation as resolved.
Show resolved Hide resolved
... "deviceLocation": "IAD",
kalhanreddy marked this conversation as resolved.
Show resolved Hide resolved
... "summary": "details of the device",
kalhanreddy marked this conversation as resolved.
Show resolved Hide resolved
... "externalDocumentation": "details to external doc",
... }
... }
>>> DeviceCapabilities.parse_raw(json.dumps(input_json))
"""

service: DeviceServiceProperties
action: Dict[DeviceActionType, DeviceActionProperties]
deviceParameters: dict
device: DeviceLevelProperties
50 changes: 50 additions & 0 deletions src/braket/device_schema/device_level_properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2019-2019 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 typing import List, Tuple

from pydantic import BaseModel


class DeviceLevelProperties(BaseModel):
"""
DeviceCapabilities are the properties specific to device, this schema defines what is common
across all the devices

Attributes:
supportedRegions: List of the regions a device can support
deviceCost: cost of the device in USA $ . showed as [cost, factor] eg: [10, "min"]
deviceMetadata: device metadata
deviceLocation: Location of the device.
summary: Description of the device.
externalDocumentation: Documentation provided by the device provider.

Examples:
>>> import json
>>> input_json = {
... "supportedRegions": ["IAD"],
... "deviceCost": [10, "task"],
... "deviceMetadata": "metadata of the device",
... "deviceLocation": "IAD",
... "summary": "details of the device",
... "externalDocumentation": "details to external doc",
... }
>>> DeviceLevelProperties.parse_raw(json.dumps(input_json))
"""

supportedRegions: List[str]
kalhanreddy marked this conversation as resolved.
Show resolved Hide resolved
deviceCost: Tuple[int, str]
deviceMetadata: str
deviceLocation: str
summary: str
externalDocumentation: str
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ class DwaveDeviceCapabilities(DeviceCapabilities, BraketSchemaBase):
... }
... },
... "deviceParameters": {DwaveDeviceParameters.schema_json()},
... "device" : {
... "supportedRegions": ["IAD"],
... "deviceCost": [10, "task"],
... "deviceMetadata": "metadata of the device",
... "deviceLocation": "IAD",
... "summary": "details of the device",
... "externalDocumentation": "details to external doc",
... }
... }
>>> DwaveDeviceCapabilities.parse_raw_schema(json.dumps(input_json))
"""
Expand Down
15 changes: 14 additions & 1 deletion src/braket/device_schema/ionq/ionq_device_capabilities_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ class IonqDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
... "actionType": "braket.ir.jaqcd.program",
... "version": ["1.0", "1.1"],
... "supportedOperations": ["x", "y"],
... "supportedResultTypes": ["expectation"],
... "supportedResultTypes": [{
... "name": "resultType1",
... "observables": ["observable1"],
... "minShots": 2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"minShots": 0

... "maxShots": 4,
... }],
... }
... },
... "paradigm": {
Expand All @@ -76,6 +81,14 @@ class IonqDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
... },
... },
... "deviceParameters": {IonqDeviceParameters.schema_json()},
... "device" : {
... "supportedRegions": ["IAD"],
... "deviceCost": [10, "task"],
... "deviceMetadata": "metadata of the device",
... "deviceLocation": "IAD",
... "summary": "details of the device",
... "externalDocumentation": "details to external doc",
... }
... }
>>> IonqDeviceCapabilities.parse_raw_schema(json.dumps(input_json))
"""
Expand Down
39 changes: 37 additions & 2 deletions src/braket/device_schema/jaqcd_device_action_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,39 @@

from typing import List, Optional

from pydantic import BaseModel

from braket.device_schema.device_action_properties import DeviceActionProperties


class ResultType(BaseModel):
"""
This class provides the result type for a quantum task to return.

Attributes:

name: name of the result type
observables: supported result types for this result type.
minShots: min shots for the results
maxShots: max shots for the results

Examples:
>>> import json
>>> input_json = {
... "name": "resultType1",
... "observables": ["observable1"],
... "minShots": 2,
... "maxShots": 4,
... }
>>> ResultType.parse_raw(json.dumps(input_json))
"""

name: str
observables: Optional[List[str]]
minShots: Optional[int]
maxShots: Optional[int]


class JaqcdDeviceActionProperties(DeviceActionProperties):

"""
Expand All @@ -32,11 +62,16 @@ class JaqcdDeviceActionProperties(DeviceActionProperties):
... "actionType": "braket.ir.jaqcd.program",
... "version": ["1.0", "1.1"],
... "supportedOperations": ["x", "y"],
... "supportedResultTypes": ["expectation"],
... "supportedResultTypes": [{
... "name": "resultType1",
... "observables": ["observable1"],
... "minShots": 2,
kalhanreddy marked this conversation as resolved.
Show resolved Hide resolved
... "maxShots": 4,
... }],
... }
>>> JaqcdDeviceActionProperties.parse_raw(json.dumps(input_json))

"""

supportedOperations: List[str]
supportedResultTypes: Optional[List[str]]
supportedResultTypes: Optional[List[ResultType]]
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ class RigettiDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
... "actionType": "braket.ir.jaqcd.program",
... "version": ["1.0", "1.1"],
... "supportedOperations": ["x", "y"],
... "supportedResultTypes": ["expectation"],
... "supportedResultTypes": [{
... "name": "resultType1",
... "observables": ["observable1"],
... "minShots": 2,
... "maxShots": 4,
... }],
... }
... },
... "paradigm": {
Expand All @@ -75,6 +80,14 @@ class RigettiDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
... },
... },
... "deviceParameters": {RigettiDeviceParameters.schema_json()},
... "device" : {
... "supportedRegions": ["IAD"],
... "deviceCost": [10, "task"],
... "deviceMetadata": "metadata of the device",
... "deviceLocation": "IAD",
... "summary": "details of the device",
... "externalDocumentation": "details to external doc",
... }
... }
>>> RigettiDeviceCapabilities.parse_raw_schema(json.dumps(input_json))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ class GateModelSimulatorDeviceCapabilities(BraketSchemaBase, DeviceCapabilities)
... "actionType": "braket.ir.jaqcd.program",
... "version": ["1.0", "1.1"],
... "supportedOperations": ["x", "y"],
... "supportedResultTypes": ["expectation"],
... "supportedResultTypes":[{
... "name": "resultType1",
... "observables": ["observable1"],
... "minShots": 2,
... "maxShots": 4,
... }],
... }
... },
... "paradigm": {
Expand All @@ -71,7 +76,15 @@ class GateModelSimulatorDeviceCapabilities(BraketSchemaBase, DeviceCapabilities)
... },
... "qubitCount": 31
... },
... "deviceParameters": {GateModelSimulatorDeviceParameters.schema_json()}
... "deviceParameters": {GateModelSimulatorDeviceParameters.schema_json()},
... "device" : {
... "supportedRegions": ["IAD"],
... "deviceCost": [10, "task"],
... "deviceMetadata": "metadata of the device",
... "deviceLocation": "IAD",
... "summary": "details of the device",
... "externalDocumentation": "details to external doc",
... }
... }
>>> GateModelSimulatorDeviceCapabilities.parse_raw_schema(json.dumps(input_json))

Expand Down
1 change: 1 addition & 0 deletions src/braket/task_result/rigetti_metadata_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class NativeQuilMetadata(BaseModel):
qpuRuntimeEstimation=191.21,
topologicalSwaps=0)
"""

finalRewiring: conlist(int)
gateDepth: conint(ge=0)
gateVolume: conint(ge=0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ def valid_input():
}
},
},
"device": {
"supportedRegions": ["IAD"],
"deviceCost": [10, "task"],
"deviceMetadata": "metadata of the device",
"deviceLocation": "IAD",
"summary": "details of the device",
"externalDocumentation": "details to external doc",
},
}
return input

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ def valid_input():
"actionType": "braket.ir.jaqcd.program",
"version": ["1.0", "1.1"],
"supportedOperations": ["x", "y"],
"supportedResultTypes": ["expectation"],
"supportedResultTypes": [
{
"name": "resultType1",
"observables": ["observable1"],
"minShots": 2,
"maxShots": 4,
}
],
}
},
"paradigm": {
Expand All @@ -58,6 +65,14 @@ def valid_input():
"connectivity": {"fullyConnected": False, "connectivityGraph": {"1": ["2", "3"]},},
},
"deviceParameters": {},
"device": {
"supportedRegions": ["IAD"],
"deviceCost": [10, "task"],
"deviceMetadata": "metadata of the device",
"deviceLocation": "IAD",
"summary": "details of the device",
"externalDocumentation": "details to external doc",
},
}
return input

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ def valid_input():
"actionType": "braket.ir.jaqcd.program",
"version": ["1.0", "1.1"],
"supportedOperations": ["x", "y"],
"supportedResultTypes": ["expectation"],
"supportedResultTypes": [
{
"name": "resultType1",
"observables": ["observable1"],
"minShots": 2,
"maxShots": 4,
}
],
}
},
"paradigm": {
Expand All @@ -58,6 +65,14 @@ def valid_input():
"connectivity": {"fullyConnected": False, "connectivityGraph": {"1": ["2", "3"]},},
},
"deviceParameters": {},
"device": {
"supportedRegions": ["IAD"],
"deviceCost": [10, "task"],
"deviceMetadata": "metadata of the device",
"deviceLocation": "IAD",
"summary": "details of the device",
"externalDocumentation": "details to external doc",
},
}
return input

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ def valid_input():
"actionType": "braket.ir.jaqcd.program",
"version": ["1.0", "1.1"],
"supportedOperations": ["x", "y"],
"supportedResultTypes": ["expectation"],
"supportedResultTypes": [
{
"name": "resultType1",
"observables": ["observable1"],
"minShots": 2,
"maxShots": 4,
}
],
}
},
"paradigm": {
Expand All @@ -64,6 +71,14 @@ def valid_input():
},
"paradigmParameters": {},
},
"device": {
"supportedRegions": ["IAD"],
"deviceCost": [10, "task"],
"deviceMetadata": "metadata of the device",
"deviceLocation": "IAD",
"summary": "details of the device",
"externalDocumentation": "details to external doc",
},
}
return input

Expand Down
8 changes: 8 additions & 0 deletions test/braket/device_schema/test_device_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ def valid_input():
}
},
"deviceParameters": {},
"device": {
"supportedRegions": ["IAD"],
"deviceCost": [10, "task"],
"deviceMetadata": "metadata of the device",
"deviceLocation": "IAD",
"summary": "details of the device",
"externalDocumentation": "details to external doc",
},
}
return input

Expand Down
Loading