# Backpropagation with lightning.qubit and PyTorch

**URL:** <https://discuss.pennylane.ai/t/backpropagation-with-lightning-qubit-and-pytorch/1650>\
**Category:** PennyLane Help\
**Created:** [February 5, 2022, 5:06pm UTC](https://discuss.pennylane.ai/t/backpropagation-with-lightning-qubit-and-pytorch/1650 "2022-02-05T17:06:15Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [February 7, 2022, 7:25am UTC](https://discuss.pennylane.ai/t/backpropagation-with-lightning-qubit-and-pytorch/1650/2 "2022-02-07T07:25:35Z")

</div>

Hi @karolishp — a very well-founded question!

Everything you note is correct:

- `backprop` definitely has an overhead on the forward pass, since every intermediate stage of the computation is being stored in memory, to be accumulated later during the backwards pass.

- The `adjoint` method is a version of backprop that is designed for unitary/reversible computation — as a result, we are able to remove the memory caching requirements, and replace it with some additional computation. In effect, we are trading a reduction in memory for an increase in computational time, however, this allows us to scale up the regimes where we can use adjoint beyond standard backprop, to ~30 qubits or more.

- `parameter-shift` will have the _fastest_ forward execution time (since there is no ‘bookkeeping’ that must be done on the forward pass), but requires 2P separate circuit evaluations on the backwards pass, for all P parameters in the circuit. So useful for small circuits with few parameters, but rapidly becomes unscalable as the number of parameters/qubits increase.

> Following [Backpropagation with Pytorch](http://discuss.pennylane.ai/t/backpropagation-with-pytorch/805/2), I tried `lightning.qubit` with `adjoint` , however there are some operations I use that are not supported by adjoint, so that’s not a valid option for my use case.

Which operations/measurements do you currently need which aren’t supported with adjoint yet? This will help us build up the adjoint to ensure feature parity.

> P.S. I also noticed that using `default.qubit` with `backprop` on PyTorch (as well as `default.qubit.torch` ) gives the following warning message:

Would you be able to post:

- A small QNode example that generates this warning?
- Your Torch, PennyLane, and NumPy versions?

This will help us track down the issue 🙂

---

_[View the full topic](https://discuss.pennylane.ai/t/backpropagation-with-lightning-qubit-and-pytorch/1650)._
