Skip to content

Commit

Permalink
Adding Device Documentation Properties (#25)
Browse files Browse the repository at this point in the history
* updating resultTypes for jaqcd also add device properties

* Adding example for task result

* Updating the device metadata

* fixing missed comments:

* updaing the naming of the device metadata

* Fixed missing some comments

Co-authored-by: 🐅ⓚ <vundela@amazon.com>
  • Loading branch information
kalhanreddy and 🐅ⓚ committed Jul 30, 2020
1 parent b22ad42 commit 353f173
Show file tree
Hide file tree
Showing 15 changed files with 238 additions and 13 deletions.
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 @@ -47,14 +47,24 @@ class DeviceCapabilities(BaseModel):
... }
... ],
... "shotsRange": [1, 10],
... "deviceCost": {
... "price": 0.25,
... "unit": "minute"
... },
... "deviceDocumentation": {
... "imageUrl": "image_url",
... "summary": "Summary on the device",
... "externalDocumentationUrl": "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},
... }
>>> 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 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 DeviceDocumentation(BaseModel):
"""
This class provides the device documentations like image, summary of it and external documentation.
Attributes:
imageUrl: url for the image of the device
summary: brief description on the device
externalDocumentationUrl: link to provide any useful information to the users.
Examples:
>>> import json
>>> input_json = {
... "imageUrl": "image_url",
... "summary": "Summary on the device",
... "externalDocumentationUrl": "exter doc link",
... }
>>> DeviceDocumentation.parse_raw(json.dumps(input_json))
"""

imageUrl: Optional[str]
summary: Optional[str]
externalDocumentationUrl: 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"
... },
... "deviceDocumentation": {
... "imageUrl": "image_url",
... "summary": "Summary on the device",
... "externalDocumentationUrl": "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]
deviceDocumentation: Optional[DeviceDocumentation]
deviceLocation: Optional[str]
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"
... },
... "deviceDocumentation": {
... "imageUrl": "image_url",
... "summary": "Summary on the device",
... "externalDocumentationUrl": "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"
... },
... "deviceDocumentation": {
... "imageUrl": "image_url",
... "summary": "Summary on the device",
... "externalDocumentationUrl": "external 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": 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"
... },
... "deviceDocumentation": {
... "imageUrl": "image_url",
... "summary": "Summary on the device",
... "externalDocumentationUrl": "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": 0,
... "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"
... },
... "deviceDocumentation": {
... "imageUrl": "image_url",
... "summary": "Summary on the device",
... "externalDocumentationUrl": "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": 0,
... "maxShots": 4,
... }],
... }
... },
... "paradigm": {
Expand All @@ -71,7 +86,7 @@ class GateModelSimulatorDeviceCapabilities(BraketSchemaBase, DeviceCapabilities)
... },
... "qubitCount": 31
... },
... "deviceParameters": {GateModelSimulatorDeviceParameters.schema_json()}
... "deviceParameters": {GateModelSimulatorDeviceParameters.schema_json()},
... }
>>> 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"},
"deviceDocumentation": {
"imageUrl": "image_url",
"summary": "Summary on the device",
"externalDocumentationUrl": "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"},
"deviceDocumentation": {
"imageUrl": "image_url",
"summary": "Summary on the device",
"externalDocumentationUrl": "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 @@ -39,13 +39,27 @@ def valid_input():
}
],
"shotsRange": [1, 10],
"deviceCost": {"price": 0.25, "unit": "minute"},
"deviceDocumentation": {
"imageUrl": "image_url",
"summary": "Summary on the device",
"externalDocumentationUrl": "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 @@ -41,13 +41,27 @@ def valid_input():
}
],
"shotsRange": [1, 10],
"deviceCost": {"price": 0.25, "unit": "minute"},
"deviceDocumentation": {
"imageUrl": "image_url",
"summary": "Summary on the device",
"externalDocumentationUrl": "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
Loading

0 comments on commit 353f173

Please sign in to comment.