{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Adjoint gradient computation with PennyLane and Amazon Braket" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Use Braket SDK Cost Tracking to estimate the cost to run this example\n", "from braket.tracking import Tracker\n", "t = Tracker().start()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This tutorial will show you how to compute gradients of free parameters in a quantum circuit using PennyLane and Amazon Braket. Check out the [example notebook](../../braket_features/Using_The_Adjoint_Gradient_Result_Type.ipynb) about the adjoint gradient method and [PennyLane's tutorial](https://pennylane.ai/qml/demos/tutorial_adjoint_diff.html) to learn the basics of the adjoint method. This tutorial builds on the [Quantum Chemistry with VQE example notebook](../3_Quantum_chemistry_with_VQE/3_Quantum_chemistry_with_VQE.ipynb) and the [PennyLane demo on adaptive circuits](https://pennylane.ai/qml/demos/tutorial_adaptive_circuits.html)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Brief introduction to the adjoint differentiation method" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Adjoint differentiation is a technique used to compute gradients of parametrized quantum circuits. It can be used when `shots=0` and is available on Amazon Braket's on-demand state vector simulator, SV1. The adjoint differentiation method allows you to compute the gradient of a circuit with `P` parameters in only 1+1 circuit executions (one forward and one backward pass, similar to backpropagation), as opposed to the parameter-shift or finite-difference methods, both of which require `2P` circuit executions for every gradient calculation. The adjoint method can lower the cost of running variational quantum workflows, especially for circuits with a large number of parameters." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
circuit_1
to compute the cost.\n",
"parameter-shift
rather than extrapolating.\n",
"doubles
independently and submit the computations to run concurrently) and see if that can improve wallclock performance.\n",
"