Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning message to Gradients and training documentation about ComplexWarnings #6543

Merged
merged 10 commits into from
Nov 8, 2024
11 changes: 11 additions & 0 deletions doc/introduction/interfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ a :class:`QNode <pennylane.QNode>`, e.g.,
If no interface is specified, PennyLane will automatically determine the interface based on provided arguments and keyword arguments.
See ``qml.workflow.SUPPORTED_INTERFACES`` for a list of all accepted interface strings.

.. warning::

``ComplexWarning`` messages may appear when running differentiable workflows involving both complex and float types, particularly
with certain interfaces. These warnings are common in backpropagation due to the nature of complex casting and do not
indicate an error in computation. If desired, you can suppress these warnings by adding the following code:

.. code-block:: python

import warnings
warnings.filterwarnings("ignore", category=np.ComplexWarning)

This will allow native numerical objects of the specified library (NumPy arrays, JAX arrays, Torch Tensors,
or TensorFlow Tensors) to be passed as parameters to the quantum circuit. It also makes
the gradients of the quantum circuit accessible to the classical library, enabling the
Expand Down
6 changes: 5 additions & 1 deletion doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@

<h3>Documentation 📝</h3>

* Add a warning message to Gradients and training documentation about ComplexWarnings
[(#6543)](https://github.com/PennyLaneAI/pennylane/pull/6543)

<h3>Bug fixes 🐛</h3>

<h3>Contributors ✍️</h3>

This release contains contributions from (in alphabetical order):

Astral Cai,
Andrija Paurevic
Andrija Paurevic,
Justin Pickering