From fd4029e50a554bcdd2d4ac1af8061ab55e4bce02 Mon Sep 17 00:00:00 2001 From: Angela Guo Date: Fri, 26 Jan 2024 13:25:25 -0800 Subject: [PATCH] ran linter to fix formatting issue --- src/braket/pennylane_plugin/braket_device.py | 19 ++-- src/braket/pennylane_plugin/ops.py | 8 ++ test/unit_tests/test_ahs_device.py | 92 ++++++++++---------- 3 files changed, 68 insertions(+), 51 deletions(-) diff --git a/src/braket/pennylane_plugin/braket_device.py b/src/braket/pennylane_plugin/braket_device.py index 93a352a0..a16838c2 100644 --- a/src/braket/pennylane_plugin/braket_device.py +++ b/src/braket/pennylane_plugin/braket_device.py @@ -109,6 +109,7 @@ class BraketQubitDevice(QubitDevice): Default: True. `**run_kwargs`: Variable length keyword arguments for ``braket.devices.Device.run()``. """ + name = "Braket PennyLane plugin" pennylane_requires = ">=0.30.0" version = __version__ @@ -287,9 +288,11 @@ def _braket_to_pl_result(self, braket_result, circuit): # to submit another result type alongside adjoint gradient, this logic will need to # change. results_list = [ - np.asarray(result, dtype="object") - if isinstance(result, collections.abc.Sequence) - else result + ( + np.asarray(result, dtype="object") + if isinstance(result, collections.abc.Sequence) + else result + ) for result in results ] return results_list[0] @@ -538,6 +541,7 @@ class BraketAwsQubitDevice(BraketQubitDevice): supports the native gate set of the device. Default False. `**run_kwargs`: Variable length keyword arguments for ``braket.devices.Device.run()``. """ + name = "Braket AwsDevice for PennyLane" short_name = "braket.aws.qubit" @@ -629,9 +633,11 @@ def batch_execute(self, circuits, **run_kwargs): max_connections=self._max_connections, poll_timeout_seconds=self._poll_timeout_seconds, poll_interval_seconds=self._poll_interval_seconds, - inputs=[{f"p_{k}": v for k, v in trainable.items()} for trainable in all_trainable] - if self._parametrize_differentiable - else [], + inputs=( + [{f"p_{k}": v for k, v in trainable.items()} for trainable in all_trainable] + if self._parametrize_differentiable + else [] + ), **self._run_kwargs, ) # Call results() to retrieve the Braket results in parallel. @@ -993,6 +999,7 @@ class BraketLocalQubitDevice(BraketQubitDevice): Default: None `**run_kwargs`: Variable length keyword arguments for ``braket.devices.Device.run()``. """ + name = "Braket LocalSimulator for PennyLane" short_name = "braket.local.qubit" diff --git a/src/braket/pennylane_plugin/ops.py b/src/braket/pennylane_plugin/ops.py index 4c3856c5..83c19ad8 100644 --- a/src/braket/pennylane_plugin/ops.py +++ b/src/braket/pennylane_plugin/ops.py @@ -85,6 +85,7 @@ class CPhaseShift00(Operation): id (str, optional): String representing the operation. Default: None """ + num_params = 1 num_wires = 2 grad_method = "A" @@ -148,6 +149,7 @@ class CPhaseShift01(Operation): wires (int): the subsystem the gate acts on id (str or None): String representing the operation (optional) """ + num_params = 1 num_wires = 2 grad_method = "A" @@ -209,6 +211,7 @@ class CPhaseShift10(Operation): wires (int): the subsystem the gate acts on id (str or None): String representing the operation (optional) """ + num_params = 1 num_wires = 2 grad_method = "A" @@ -269,6 +272,7 @@ class PSWAP(Operation): wires (int): the subsystem the gate acts on id (str or None): String representing the operation (optional) """ + num_params = 1 num_wires = 2 grad_method = "A" @@ -316,6 +320,7 @@ class GPi(Operation): wires (int): the subsystem the gate acts on id (str or None): String representing the operation (optional) """ + num_params = 1 num_wires = 1 grad_method = "F" @@ -358,6 +363,7 @@ class GPi2(Operation): wires (int): the subsystem the gate acts on id (str or None): String representing the operation (optional) """ + num_params = 1 num_wires = 1 grad_method = "F" @@ -404,6 +410,7 @@ class MS(Operation): wires (int): the subsystem the gate acts on id (str or None): String representing the operation (optional) """ + num_params = 2 num_wires = 2 grad_method = "F" @@ -455,6 +462,7 @@ class AAMS(Operation): wires (int): the subsystem the gate acts on id (str or None): String representing the operation (optional) """ + num_params = 3 num_wires = 2 grad_method = "F" diff --git a/test/unit_tests/test_ahs_device.py b/test/unit_tests/test_ahs_device.py index 0c8e77b2..e7eaf5a1 100644 --- a/test/unit_tests/test_ahs_device.py +++ b/test/unit_tests/test_ahs_device.py @@ -164,52 +164,54 @@ def dummy_cfunc(t): }, }, "performance": { - "lattice": {"positionErrorAbs": 1.47e-7, - "sitePositionError": 0.025e-6, - "atomPositionError": 0.025e-6, - "fillingErrorTypical": 0.005, - "fillingErrorWorst": 0.01, - "vacancyErrorTypical": 0.005, - "vacancyErrorWorst": 0.005, - "atomLossProbabilityTypical": 0.01, - "atomLossProbabilityWorst": 0.01, - "atomCaptureProbabilityTypical": 0.01, - "atomCaptureProbabilityWorst": 0.01, - "atomDetectionErrorFalsePositiveTypical": 0.01, - "atomDetectionErrorFalsePositiveWorst": 0.01, - "atomDetectionErrorFalseNegativeTypical": 0.01, - "atomDetectionErrorFalseNegativeWorst": 0.01, - }, - "rydberg": {"rydbergGlobal": { - "rabiFrequencyErrorRel": 0.02, - "rabiFrequencyGlobalErrorRel": 0.01, - "rabiFrequencyInhomogeneityRel": 0.01, - "groundDetectionError": 0.01, - "rydbergDetectionError": 0.1, - "groundPrepError": 0.01, - "rydbergPrepErrorBest": 0.05, - "rydbergPrepErrorWorst": 0.05, - "T1Single": 100e-6, - "T1Ensemble": 100e-6, - "T2StarSingle": 5e-6, - "T2StarEnsemble": 5e-6, - "T2EchoSingle": 5e-6, - "T2EchoEnsemble": 5e-6, - "T2RabiSingle": 5e-6, - "T2RabiEnsemble": 5e-6, - "T2BlockadedRabiSingle": 5e-6, - "T2BlockadedRabiEnsemble": 5e-6, - "detuningError": 1e6, - "detuningInhomogeneity": 1e6, - "rabiAmplitudeRampCorrection": [ - {"rampTime": 50e-9, "rabiCorrection": 0.92}, - {"rampTime": 75e-9, "rabiCorrection": 0.97}, - {"rampTime": 100e-9, "rabiCorrection": 1.00}, - ], - }, - }, + "lattice": { + "positionErrorAbs": 1.47e-7, + "sitePositionError": 0.025e-6, + "atomPositionError": 0.025e-6, + "fillingErrorTypical": 0.005, + "fillingErrorWorst": 0.01, + "vacancyErrorTypical": 0.005, + "vacancyErrorWorst": 0.005, + "atomLossProbabilityTypical": 0.01, + "atomLossProbabilityWorst": 0.01, + "atomCaptureProbabilityTypical": 0.01, + "atomCaptureProbabilityWorst": 0.01, + "atomDetectionErrorFalsePositiveTypical": 0.01, + "atomDetectionErrorFalsePositiveWorst": 0.01, + "atomDetectionErrorFalseNegativeTypical": 0.01, + "atomDetectionErrorFalseNegativeWorst": 0.01, + }, + "rydberg": { + "rydbergGlobal": { + "rabiFrequencyErrorRel": 0.02, + "rabiFrequencyGlobalErrorRel": 0.01, + "rabiFrequencyInhomogeneityRel": 0.01, + "groundDetectionError": 0.01, + "rydbergDetectionError": 0.1, + "groundPrepError": 0.01, + "rydbergPrepErrorBest": 0.05, + "rydbergPrepErrorWorst": 0.05, + "T1Single": 100e-6, + "T1Ensemble": 100e-6, + "T2StarSingle": 5e-6, + "T2StarEnsemble": 5e-6, + "T2EchoSingle": 5e-6, + "T2EchoEnsemble": 5e-6, + "T2RabiSingle": 5e-6, + "T2RabiEnsemble": 5e-6, + "T2BlockadedRabiSingle": 5e-6, + "T2BlockadedRabiEnsemble": 5e-6, + "detuningError": 1e6, + "detuningInhomogeneity": 1e6, + "rabiAmplitudeRampCorrection": [ + {"rampTime": 50e-9, "rabiCorrection": 0.92}, + {"rampTime": 75e-9, "rabiCorrection": 0.97}, + {"rampTime": 100e-9, "rabiCorrection": 1.00}, + ], + }, + }, }, - } + }, ) )