Skip to content

Commit

Permalink
fix jacobian bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiro-Raven committed Jul 29, 2024
1 parent e0e7079 commit cb841a1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pennylane/workflow/jacobian_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit cb841a1

Please sign in to comment.