diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md
index f5c4c9620da..dba698040ad 100644
--- a/doc/releases/changelog-dev.md
+++ b/doc/releases/changelog-dev.md
@@ -100,6 +100,7 @@
* The ``inner_transform_program`` and ``config`` keyword arguments in ``qml.execute`` have been deprecated.
If more detailed control over the execution is required, use ``qml.workflow.run`` with these arguments instead.
[(#6822)](https://github.com/PennyLaneAI/pennylane/pull/6822)
+ [(#6879)](https://github.com/PennyLaneAI/pennylane/pull/6879)
Internal changes ⚙️
diff --git a/pennylane/optimize/qnspsa.py b/pennylane/optimize/qnspsa.py
index 660f7e9ff75..93d92f4bc35 100644
--- a/pennylane/optimize/qnspsa.py
+++ b/pennylane/optimize/qnspsa.py
@@ -221,20 +221,7 @@ def _step_core(self, cost, args, kwargs):
all_grad_dirs.append(grad_dirs)
all_tensor_dirs.append(tensor_dirs)
- if isinstance(cost.device, qml.devices.Device):
- program, config = cost.device.preprocess()
-
- raw_results = qml.execute(
- all_grad_tapes + all_metric_tapes,
- cost.device,
- None,
- transform_program=program,
- config=config,
- )
- else:
- raw_results = qml.execute(
- all_grad_tapes + all_metric_tapes, cost.device, None
- ) # pragma: no cover
+ raw_results = qml.execute(all_grad_tapes + all_metric_tapes, cost.device)
grads = [
self._post_process_grad(raw_results[2 * i : 2 * i + 2], all_grad_dirs[i])
for i in range(self.resamplings)
diff --git a/pennylane/optimize/riemannian_gradient.py b/pennylane/optimize/riemannian_gradient.py
index 0b34fe76650..44d7447c236 100644
--- a/pennylane/optimize/riemannian_gradient.py
+++ b/pennylane/optimize/riemannian_gradient.py
@@ -392,31 +392,16 @@ def get_omegas(self):
self.nqubits,
)
- if isinstance(self.circuit.device, qml.devices.Device):
- program, config = self.circuit.device.preprocess()
-
- circuits = qml.execute(
- circuits,
- self.circuit.device,
- transform_program=program,
- config=config,
- diff_method=None,
- )
- else:
- circuits = qml.execute(
- circuits, self.circuit.device, diff_method=None
- ) # pragma: no cover
-
- program = self.circuit.device.preprocess_transforms()
+ raw_results = qml.execute(circuits, self.circuit.device)
- circuits_plus = np.array(circuits[: len(circuits) // 2]).reshape(
+ results_plus = np.array(raw_results[: len(raw_results) // 2]).reshape(
len(self.coeffs), len(self.lie_algebra_basis_names)
)
- circuits_min = np.array(circuits[len(circuits) // 2 :]).reshape(
+ results_min = np.array(raw_results[len(raw_results) // 2 :]).reshape(
len(self.coeffs), len(self.lie_algebra_basis_names)
)
# For each observable O_i in the Hamiltonian, we have to calculate all Lie coefficients
- omegas = circuits_plus - circuits_min
+ omegas = results_plus - results_min
return np.dot(self.coeffs, omegas)