Skip to content

Commit

Permalink
use mock DM1 in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yitchen-tim committed Jan 26, 2024
1 parent c50d8ac commit 86cdb38
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/unit_tests/braket/aws/common_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
IONQ_ARN = "arn:aws:braket:us-east-1::device/qpu/ionq/Harmony"
OQC_ARN = "arn:aws:braket:eu-west-2::device/qpu/oqc/Lucy"
SV1_ARN = "arn:aws:braket:::device/quantum-simulator/amazon/sv1"
DM1_ARN = "arn:aws:braket:::device/quantum-simulator/amazon/dm1"
TN1_ARN = "arn:aws:braket:::device/quantum-simulator/amazon/tn1"
XANADU_ARN = "arn:aws:braket:us-east-1::device/qpu/xanadu/Borealis"

Expand Down
48 changes: 46 additions & 2 deletions test/unit_tests/braket/aws/test_aws_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import pytest
from botocore.exceptions import ClientError
from common_test_utils import (
DM1_ARN,
DWAVE_ARN,
IONQ_ARN,
OQC_ARN,
Expand Down Expand Up @@ -362,6 +363,27 @@ def test_d_wave_schema():
"version": ["1"],
"supportedOperations": ["H"],
},
},
"paradigm": {"qubitCount": 30},
"deviceParameters": {},
}

MOCK_GATE_MODEL_NOISE_SIMULATOR_CAPABILITIES_JSON = {
"braketSchemaHeader": {
"name": "braket.device_schema.simulators.gate_model_simulator_device_capabilities",
"version": "1",
},
"service": {
"executionWindows": [
{
"executionDay": "Everyday",
"windowStartHour": "11:00",
"windowEndHour": "12:00",
}
],
"shotsRange": [1, 10],
},
"action": {
"braket.ir.openqasm.program": {
"actionType": "braket.ir.openqasm.program",
"version": ["1"],
Expand Down Expand Up @@ -409,6 +431,18 @@ def test_gate_model_sim_schema():
)


MOCK_GATE_MODEL_NOISE_SIMULATOR_CAPABILITIES = GateModelSimulatorDeviceCapabilities.parse_obj(
MOCK_GATE_MODEL_NOISE_SIMULATOR_CAPABILITIES_JSON
)


def test_gate_model_sim_schema():
validate(
MOCK_GATE_MODEL_NOISE_SIMULATOR_CAPABILITIES_JSON,
GateModelSimulatorDeviceCapabilities.schema(),
)


MOCK_GATE_MODEL_SIMULATOR = {
"deviceName": "SV1",
"deviceType": "SIMULATOR",
Expand All @@ -417,6 +451,16 @@ def test_gate_model_sim_schema():
"deviceCapabilities": MOCK_GATE_MODEL_SIMULATOR_CAPABILITIES.json(),
}


MOCK_GATE_MODEL_NOISE_SIMULATOR = {
"deviceName": "DM1",
"deviceType": "SIMULATOR",
"providerName": "provider1",
"deviceStatus": "ONLINE",
"deviceCapabilities": MOCK_GATE_MODEL_NOISE_SIMULATOR_CAPABILITIES.json(),
}


MOCK_DEFAULT_S3_DESTINATION_FOLDER = (
"amazon-braket-us-test-1-00000000",
"tasks",
Expand Down Expand Up @@ -2121,9 +2165,9 @@ def noise_model():
@patch("braket.aws.aws_device.AwsSession")
@patch("braket.aws.aws_quantum_task.AwsQuantumTask.create")
def test_run_with_noise_model(aws_quantum_task_mock, aws_session_init, aws_session, noise_model):
arn = SV1_ARN
arn = DM1_ARN
aws_session_init.return_value = aws_session
aws_session.get_device.return_value = MOCK_GATE_MODEL_SIMULATOR
aws_session.get_device.return_value = MOCK_GATE_MODEL_NOISE_SIMULATOR
device = AwsDevice(arn, noise_model=noise_model)
circuit = Circuit().h(0).cnot(0, 1)
_ = device.run(circuit)
Expand Down

0 comments on commit 86cdb38

Please sign in to comment.