diff --git a/pennylane/workflow/jacobian_products.py b/pennylane/workflow/jacobian_products.py index 8a93ce1de00..d4664ff0fb2 100644 --- a/pennylane/workflow/jacobian_products.py +++ b/pennylane/workflow/jacobian_products.py @@ -403,6 +403,7 @@ def __init__( ): if gradient_kwargs is None: gradient_kwargs = {} + if logger.isEnabledFor(logging.DEBUG): # pragma: no cover logger.debug( "DeviceDerivatives created with (%s, %s, %s)", @@ -415,7 +416,7 @@ def __init__( self._execution_config = execution_config self._gradient_kwargs = gradient_kwargs - self._uses_new_device = not isinstance(device, qml.devices.LegacyDevice) + self._uses_new_device = isinstance(device, qml.devices.Device) # only really need to keep most recent entry, but keeping 10 around just in case self._results_cache = LRUCache(maxsize=10) @@ -428,6 +429,7 @@ def _dev_execute_and_compute_derivatives(self, tapes: QuantumTapeBatch): Dispatches between the two different device interfaces. """ numpy_tapes, _ = qml.transforms.convert_to_numpy_parameters(tapes) + if self._uses_new_device: return self._device.execute_and_compute_derivatives(numpy_tapes, self._execution_config) return self._device.execute_and_gradients(numpy_tapes, **self._gradient_kwargs)