Skip to content

Commit

Permalink
Merge pull request #25 from aws/oqc-minor-fix
Browse files Browse the repository at this point in the history
Make provider properties specs to keep consistent with similar properties for other QHPs. Make OneQubit gate number an integer instead of a float
  • Loading branch information
MattCordoba committed Mar 18, 2022
2 parents 3f4e019 + 8599541 commit 35fd178
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 134 deletions.
36 changes: 16 additions & 20 deletions src/braket/device_schema/oqc/oqc_provider_properties_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

from typing import Dict, List, TypeVar, Union
from typing import Dict, TypeVar, Union

from pydantic import Field

Expand All @@ -20,8 +20,7 @@
# TODO: Replace the calibration data with actual values we receive from the device.


GateFidelityType = TypeVar("GateFidelityType", bound=Dict[str, Union[str, float]])
OneQubitType = TypeVar("OneQubitType", bound=Union[float, List[GateFidelityType]])
OneQubitType = TypeVar("OneQubitType", bound=Union[int, Dict[str, Union[float, int]]])
TwoQubitType = TypeVar("TwoQubitType", bound=Dict[str, Union[float, Dict[str, int]]])

QubitType = TypeVar("QubitType", bound=Dict[str, Union[OneQubitType, TwoQubitType]])
Expand All @@ -32,7 +31,7 @@ class OqcProviderProperties(BraketSchemaBase):
This defines the properties common to all the OQC devices.
Attributes:
properties (Dict[str, Dict[str, Union[int, List[int]]]]): Basic specifications for
specs (Dict[str, Dict[str, Union[OneQubitType, TwoQubitType]]): Basic specifications for
the device, such as gate fidelities and coherence times.
Examples:
Expand All @@ -42,28 +41,25 @@ class OqcProviderProperties(BraketSchemaBase):
... "name": "braket.device_schema.oqc.oqc_provider_properties",
... "version": "1",
... },
... "properties": {
... "specs": {
... "one_qubit": {
... "0": {
... "T1": 12.2,
... "T2": 13.5,
... "fRO": 0.99,
... "fRB": 0.98,
... "native-gate-fidelities": [
... {"native-gate": "rz", "CLf": 0.99},
... {"native-gate": "sx", "CLf": 0.99},
... {"native-gate": "x", "CLf": 0.99},
... ],
... "EPE": 0.001,
... "T1": 28.9,
... "T2": 44.5,
... "fRB": 99.93,
... "fRO": 90.3,
... "qubit": 0
... },
... },
... "two_qubit": {
... "0-1": {
... "coupling": {"control_qubit": 0, "target_qubit": 1},
... "CLf": 0.99,
... "ECR_f": 0.99,
... "coupling": {
... "control_qubit": 0,
... "target_qubit": 1
... },
... "fCX": 87.7
... },
... },
... }
... },
... }
>>> OqcProviderProperties.parse_raw_schema(json.dumps(input_json))
Expand All @@ -73,4 +69,4 @@ class OqcProviderProperties(BraketSchemaBase):
name="braket.device_schema.oqc.oqc_provider_properties", version="1"
)
braketSchemaHeader: BraketSchemaHeader = Field(default=_PROGRAM_HEADER, const=_PROGRAM_HEADER)
properties: Dict[str, Dict[str, QubitType]]
specs: Dict[str, Dict[str, QubitType]]
Original file line number Diff line number Diff line change
Expand Up @@ -26,145 +26,49 @@ def valid_input():
"name": "braket.device_schema.oqc.oqc_provider_properties",
"version": "1",
},
"properties": {
"specs": {
"one_qubit": {
"0": {
"T1": 12.2,
"T2": 13.5,
"fRO": 0.99,
"fRB": 0.98,
"native_gate_fidelities": [
{"native_gate": "rz", "CLf": 0.99},
{"native_gate": "sx", "CLf": 0.99},
{"native_gate": "x", "CLf": 0.99},
],
"EPE": 0.001,
},
"1": {
"T1": 12.2,
"T2": 13.5,
"fRO": 0.99,
"fRB": 0.98,
"native_gate_fidelities": [
{"native_gate": "rz", "CLf": 0.99},
{"native_gate": "sx", "CLf": 0.99},
{"native_gate": "x", "CLf": 0.99},
],
"EPE": 0.001,
},
"2": {
"T1": 12.2,
"T2": 13.5,
"fRO": 0.99,
"fRB": 0.98,
"native_gate_fidelities": [
{"native_gate": "rz", "CLf": 0.99},
{"native_gate": "sx", "CLf": 0.99},
{"native_gate": "x", "CLf": 0.99},
],
"EPE": 0.001,
},
"3": {
"T1": 12.2,
"T2": 13.5,
"fRO": 0.99,
"fRB": 0.98,
"native_gate_fidelities": [
{"native_gate": "rz", "CLf": 0.99},
{"native_gate": "sx", "CLf": 0.99},
{"native_gate": "x", "CLf": 0.99},
],
"EPE": 0.001,
},
"4": {
"T1": 12.2,
"T2": 13.5,
"fRO": 0.99,
"fRB": 0.98,
"native_gate_fidelities": [
{"native_gate": "rz", "CLf": 0.99},
{"native_gate": "sx", "CLf": 0.99},
{"native_gate": "x", "CLf": 0.99},
],
"EPE": 0.001,
},
"5": {
"T1": 12.2,
"T2": 13.5,
"fRO": 0.99,
"fRB": 0.98,
"native_gate_fidelities": [
{"native_gate": "rz", "CLf": 0.99},
{"native_gate": "sx", "CLf": 0.99},
{"native_gate": "x", "CLf": 0.99},
],
"EPE": 0.001,
},
"6": {
"T1": 12.2,
"T2": 13.5,
"fRO": 0.99,
"fRB": 0.98,
"native_gate_fidelities": [
{"native_gate": "rz", "CLf": 0.99},
{"native_gate": "sx", "CLf": 0.99},
{"native_gate": "x", "CLf": 0.99},
],
"EPE": 0.001,
},
"7": {
"T1": 12.2,
"T2": 13.5,
"fRO": 0.99,
"fRB": 0.98,
"native_gate_fidelities": [
{"native_gate": "rz", "CLf": 0.99},
{"native_gate": "sx", "CLf": 0.99},
{"native_gate": "x", "CLf": 0.99},
],
"EPE": 0.001,
},
"0": {"T1": 12.2, "T2": 13.5, "fRO": 0.99, "fRB": 0.98, "qubit": 0},
"1": {"T1": 12.2, "T2": 13.5, "fRO": 0.99, "fRB": 0.98, "qubit": 1},
"2": {"T1": 12.2, "T2": 13.5, "fRO": 0.99, "fRB": 0.98, "qubit": 2},
"3": {"T1": 12.2, "T2": 13.5, "fRO": 0.99, "fRB": 0.98, "qubit": 3},
"4": {"T1": 12.2, "T2": 13.5, "fRO": 0.99, "fRB": 0.98, "qubit": 4},
"5": {"T1": 12.2, "T2": 13.5, "fRO": 0.99, "fRB": 0.98, "qubit": 5},
"6": {"T1": 12.2, "T2": 13.5, "fRO": 0.99, "fRB": 0.98, "qubit": 6},
"7": {"T1": 12.2, "T2": 13.5, "fRO": 0.99, "fRB": 0.98, "qubit": 7},
},
"two_qubit": {
"0-1": {
"coupling": {"control_qubit": 0, "target_qubit": 1},
"CLf": 0.99,
"ECR_f": 0.99,
"fCX": 0.99,
},
"1-2": {
"coupling": {"control_qubit": 1, "target_qubit": 2},
"CLf": 0.99,
"ECR_f": 0.99,
"fCX": 0.99,
},
"2-3": {
"coupling": {"control_qubit": 2, "target_qubit": 3},
"CLf": 0.99,
"ECR_f": 0.99,
"fCX": 0.99,
},
"3-4": {
"coupling": {"control_qubit": 3, "target_qubit": 4},
"CLf": 0.99,
"ECR_f": 0.99,
"fCX": 0.99,
},
"4-5": {
"coupling": {"control_qubit": 4, "target_qubit": 5},
"CLf": 0.99,
"ECR_f": 0.99,
"fCX": 0.99,
},
"5-6": {
"coupling": {"control_qubit": 5, "target_qubit": 6},
"CLf": 0.99,
"ECR_f": 0.99,
"fCX": 0.99,
},
"6-7": {
"coupling": {"control_qubit": 6, "target_qubit": 7},
"CLf": 0.99,
"ECR_f": 0.99,
"fCX": 0.99,
},
"7-0": {
"coupling": {"control_qubit": 7, "target_qubit": 0},
"CLf": 0.99,
"ECR_f": 0.99,
"fCX": 0.99,
},
},
},
Expand All @@ -177,7 +81,7 @@ def test_valid(valid_input):
assert result.braketSchemaHeader.name == "braket.device_schema.oqc.oqc_provider_properties"


@pytest.mark.parametrize("missing_field", ["braketSchemaHeader", "properties"])
@pytest.mark.parametrize("missing_field", ["braketSchemaHeader", "specs"])
def test_missing_field(valid_input, missing_field):
with pytest.raises(ValidationError):
valid_input.pop(missing_field)
Expand Down

0 comments on commit 35fd178

Please sign in to comment.