# Gradient decent

**URL:** <https://discuss.pennylane.ai/t/gradient-decent/74>\
**Category:** PennyLane Help\
**Created:** [January 28, 2019, 12:57am UTC](https://discuss.pennylane.ai/t/gradient-decent/74 "2019-01-28T00:57:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kareem\_essafty](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/kareem_essafty/32/401_2.png) [@kareem\_essafty](https://discuss.pennylane.ai/u/kareem_essafty)\
**Post date:** [January 28, 2019, 12:57am UTC](https://discuss.pennylane.ai/t/gradient-decent/74/1 "2019-01-28T00:57:43Z")

</div>

I’d like to be certain about the nature of the gradient that is obtained in pennylane

is the gradient computed classically or quantumly in pennylane?  
[this paper](https://arxiv.org/pdf/1811.11184.pdf) by prof @Maria_Schuld presents a very promising results.

I think and please correct me if i’m wrong, according to your [docs](https://pennylane.readthedocs.io/en/latest/concepts/autograd_quantum.html#autograd-quantum) the gradients are quantum in its own nature, aren’t they?

---

<div class="post-metadata">

**Author:** ![josh](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/josh/32/100_2.png) [@josh](https://discuss.pennylane.ai/u/josh)\
**Post date:** [January 28, 2019, 2:52am UTC](https://discuss.pennylane.ai/t/gradient-decent/74/2 "2019-01-28T02:52:04Z")

</div>

Hi @kareem_essafty, that is correct, the gradients are computed by sampling the quantum hardware directly, as in the paper you linked 🙂

In general, PennyLane has two approaches to calculating the gradient on quantum hardware:

1. **Analytic gradients** : these are supported by all qubit-model QNodes, as well as all Gaussian continuous-variable circuits. This is done by sampling the quantum devices at two additional parameter values, proving the **exact** gradient.

2. **Finite-difference** : In the few cases where analytic gradients are not supported, for instance, if the QNode contains a non-Gaussian gate (e.g., a Kerr interaction or cubic phase gate) _in-between_ the gate to be differentiated and the expectation value {}^1, then PennyLane falls-back to the finite-difference approximation.

* * *

{}^1 if the non-Gaussian gate _precedes_ the gate that is differentiated, then analytic differentiation is still supported.
