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 4 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
20 changes: 19 additions & 1 deletion src/braket/device_schema/device_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,32 @@ class DeviceCapabilities(BaseModel):
... }
... ],
... "shotsRange": [1, 10],
... "deviceCost": {
... "price": 0.25,
... "unit": "minute"
... },
... "deviceMetadata": {
... "image": "image_url",
... "summary": "Summary on the device",
... "externalDocumentation": "exter doc link",
... },
... "deviceLocation": "us-east-1"
... },
... "action": {
... "braket.ir.jaqcd.program": {
... "actionType": "braket.ir.jaqcd.program",
... "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))
"""
Expand Down
63 changes: 61 additions & 2 deletions src/braket/device_schema/device_service_properties_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,60 @@
# 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 typing import List, Optional, Tuple

from pydantic import Field
from pydantic import BaseModel, Field

from braket.device_schema.device_execution_window import DeviceExecutionWindow
from braket.schema_common import BraketSchemaBase, BraketSchemaHeader


class DeviceCost(BaseModel):

"""
This class provides the details on the cost of a device.

Attributes:
price: Price of the device in terms of US $
Copy link
Contributor

Choose a reason for hiding this comment

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

"US dollars"

unit: unit for charging the price, eg: minute, hour, task [price per task]

Examples:
>>> import json
>>> input_json = {
... "price": 0.25,
... "unit": "minute"
... }
>>> DeviceCost.parse_raw(json.dumps(input_json))
"""

price: float
unit: str


class DeviceMetadata(BaseModel):
kalhanreddy marked this conversation as resolved.
Show resolved Hide resolved
"""
This class provides the device metadata like image, summary of it and external documentation.
Copy link
Contributor

Choose a reason for hiding this comment

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

"device documentation"


Attributes:
imageUrl: url for the image of the device
summary: brief description on the device
externalDocumentationLink: link to provide any useful information to the users.
Copy link
Contributor

Choose a reason for hiding this comment

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

externalDocumentationUrl


Examples:
>>> import json
>>> input_json = {
... "image": "image_url",
kalhanreddy marked this conversation as resolved.
Show resolved Hide resolved
... "summary": "Summary on the device",
... "externalDocumentation": "exter doc link",
kalhanreddy marked this conversation as resolved.
Show resolved Hide resolved
... }
>>> DeviceMetadata.parse_raw(json.dumps(input_json))
"""

imageUrl: Optional[str]
summary: Optional[str]
externalDocumentationLink: Optional[str]


class DeviceServiceProperties(BraketSchemaBase):
"""
This class defines the common service properties for each device.
Expand All @@ -43,6 +89,16 @@ class DeviceServiceProperties(BraketSchemaBase):
... }
... ],
... "shotsRange": [1,10],
... "deviceCost": {
... "price": 0.25,
... "unit": "minute"
... },
... "deviceMetadata": {
... "image": "image_url",
... "summary": "Summary on the device",
... "externalDocumentation": "exter doc link",
... },
... "deviceLocation": "us-east-1"
... }
>>> DeviceServiceProperties.parse_raw_schema(json.dumps(input_json))

Expand All @@ -54,3 +110,6 @@ class DeviceServiceProperties(BraketSchemaBase):
braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
executionWindows: List[DeviceExecutionWindow]
shotsRange: Tuple[int, int]
deviceCost: Optional[DeviceCost]
deviceMetadata: Optional[DeviceMetadata]
deviceLocation: str
kalhanreddy marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 10 additions & 0 deletions src/braket/device_schema/dwave/dwave_device_capabilities_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ class DwaveDeviceCapabilities(DeviceCapabilities, BraketSchemaBase):
... }
... ],
... "shotsRange": [1, 10],
... "deviceCost": {
... "price": 0.25,
... "unit": "minute"
... },
... "deviceMetadata": {
... "image": "image_url",
... "summary": "Summary on the device",
... "externalDocumentation": "exter doc link",
... },
... "deviceLocation": "us-east-1"
... },
... "action": {
... "braket.ir.jaqcd.program": {
Expand Down
17 changes: 16 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 @@ -54,13 +54,28 @@ class IonqDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
... }
... ],
... "shotsRange": [1, 10],
... "deviceCost": {
... "price": 0.25,
... "unit": "minute"
... },
... "deviceMetadata": {
... "image": "image_url",
... "summary": "Summary on the device",
... "externalDocumentation": "exter doc link",
... },
... "deviceLocation": "us-east-1"
... },
... "action": {
... "braket.ir.jaqcd.program": {
... "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 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": 0,
... "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": 0,
... "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 @@ -53,13 +53,28 @@ class RigettiDeviceCapabilities(BraketSchemaBase, DeviceCapabilities):
... }
... ],
... "shotsRange": [1, 10],
... "deviceCost": {
... "price": 0.25,
... "unit": "minute"
... },
... "deviceMetadata": {
... "image": "image_url",
... "summary": "Summary on the device",
... "externalDocumentation": "exter doc link",
... },
... "deviceLocation": "us-east-1"
... },
... "action": {
... "braket.ir.jaqcd.program": {
... "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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,28 @@ class GateModelSimulatorDeviceCapabilities(BraketSchemaBase, DeviceCapabilities)
... }
... ],
... "shotsRange": [1, 10],
... "deviceCost": {
... "price": 0.25,
... "unit": "minute"
... },
... "deviceMetadata": {
... "image": "image_url",
... "summary": "Summary on the device",
... "externalDocumentation": "exter doc link",
... },
... "deviceLocation": "us-east-1"
... },
... "action": {
... "braket.ir.jaqcd.program": {
... "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 +86,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 @@ -67,6 +67,13 @@ def valid_input():
}
],
"shotsRange": [1, 10],
"deviceCost": {"price": 0.25, "unit": "minute"},
"deviceMetadata": {
"image": "image_url",
"summary": "Summary on the device",
"externalDocumentation": "exter doc link",
},
"deviceLocation": "us-east-1",
},
"action": {
"braket.ir.jaqcd.program": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,27 @@ def valid_input():
}
],
"shotsRange": [1, 10],
"deviceCost": {"price": 0.25, "unit": "minute"},
"deviceMetadata": {
"image": "image_url",
"summary": "Summary on the device",
"externalDocumentation": "exter doc link",
},
"deviceLocation": "us-east-1",
},
"action": {
"braket.ir.jaqcd.program": {
"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 +72,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
Loading