# Using PyTorch Gradients

**URL:** <https://discuss.pennylane.ai/t/using-pytorch-gradients/747>\
**Category:** PennyLane Help\
**Created:** [December 27, 2020, 11:23am UTC](https://discuss.pennylane.ai/t/using-pytorch-gradients/747 "2020-12-27T11:23:59Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [December 28, 2020, 3:46pm UTC](https://discuss.pennylane.ai/t/using-pytorch-gradients/747/5 "2020-12-28T15:46:00Z")

</div>

> Ah apologies for not being clear. I mean if I created a cost function that itself depends on a loss, something that could look something like:

Ah, I see!

Currently, differentiating loss functions that depend on the gradient is not supported in PennyLane. This is because the second derivative of QNodes is not yet supported, however this is something we are working on adding: [https://github.com/PennyLaneAI/pennylane/pull/961](https://github.com/PennyLaneAI/pennylane/pull/961)

There is one exception, however: if you use `diff_method="backprop"`, then higher derivatives and these types of loss functions _will_ work. The following simulators support backpropagation:

- `default.qubit.tf` (must be used with `interface="tf"`)
- `default.qubit.autograd` (must be used with `interface="autograd"`)
- `strawberryfields.tf` (must be used with `interface="tf"`).

  

Note that in this case, ‘autograd’ refers to the _NumPy_-based Autograd library that is available via `from pennylane import numpy as np`, not PyTorch Autograd! Apologies for the confusion.

At the moment, there is no PyTorch-compatible simulator that supports backprop, since this requires complex number support which is not yet fully available in PyTorch.

---

_[View the full topic](https://discuss.pennylane.ai/t/using-pytorch-gradients/747)._
