Differentiable Gaussian Backend for CV Quantum ML

I am conducting research in continuous-variable (CV) quantum machine learning (ML) and have identified some strong limitations in PennyLane’s Gaussian backend that hinder its use in this area of research. I would like to discuss contributing to PennyLane with my solution!

Currently the default.gaussian backend has the following limitations:

  1. Redundant circuit evaluation: Implementing a heterodyne measurement requires building the same circuit 5 times (for means (x,p), variances (x,p), and an angled quadrature for covariance). Part of this issue is that PennyLane doesn’t allow expval() and var() of the same operator in a single circuit, despite the fact that there is no fundamental limitation for this.
  2. Non-differentiable statevector: The full Gaussian statevector (mu, cov) cannot be returned differentiably; only specific measurement results can be extracted. This prevents us from accessing the full information carried by the statevector, which is used in internal calculations!
  3. No backpropagation support: Unlike default.qubit, the Gaussian backend is limited to parameter-shift differentiation (O~2N), which becomes prohibitively slow for large circuits. This is due to how default.gaussian still relies on NumPy/SciPy operations, which cannot be automatically differentiated, as opposed to qml.math, or in my example, PyTorch tensor operations.

To combat these, I have rewritten the PennyLane Gaussian operations in PyTorch, making them fully differentiable under Autograd. This enables:

  • Backpropagation (O~1) instead of parameter-shift (O~2N)
  • Differentiable statevector return: A single circuit pass can return the full statevector (mu, cov), from which all measurement results can be derived analytically.

The speedup is substantial and makes the Gaussian backend far more suitable for ML research. The PyTorch operations could also straightforwardly be extended to qml.math, for framework-agnostic support, such as with default.qubit.

How can I best contribute this work to help improve PennyLane?

Many thanks! :smiley:

Hi @Louis_Choron, welcome to the Forum!

Unfortunately the default.gaussian device has seen very little use so we may not be able to dedicate capacity to integrating your improvements into the codebase. Let me check with the team about the best way forward.

In any case, we really appreciate your offer to contribute contribute your improvements to PennyLane.

I’ll get back to you soon!

Hi @Louis_Choron,

Thanks again for your offer to contribute to PennyLane! Unfortunately our team doesn’t have the capacity to review this potential contribution at the moment.

That being said, there are a few ways that you could make this work available to the community.

One great option is to explore contributing your work to projects that are built on top of PennyLane. Hybridlane for example, is built for CV and DV circuits, so they may find your work very useful! You could open an issue in their repo to get the conversation started.

Alternatively, if you prefer not to contribute to another project, you could create your own repository and host your improvements there.

Let us know what you decide. If you go the route of making your own repo or a third-party PR, we’d be happy to help amplify it by sharing it with our community!