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

Update the norm check for QubitStateVector in default.qubit (v0.19.1) #1924

Merged
merged 5 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/development/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Release notes
This page contains the release notes for PennyLane.


.. mdinclude:: ../releases/changelog-0.19.1.md

.. mdinclude:: ../releases/changelog-0.19.0.md

.. mdinclude:: ../releases/changelog-0.18.0.md
Expand Down
2 changes: 1 addition & 1 deletion doc/releases/changelog-0.19.0.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:orphan:

# Release 0.19.0 (current release)
# Release 0.19.0

<h3>New features since last release</h3>

Expand Down
16 changes: 16 additions & 0 deletions doc/releases/changelog-0.19.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
:orphan:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget to also add this file to release_notes.md!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch!


# Release 0.19.1 (current release)

<h3>Bug fixes</h3>

* Fixes a bug where using JAX's jit function on certain QNodes that contain
the `qml.QubitStateVector` operation raised an error with earlier JAX
versions (e.g., `jax==0.2.10` and `jaxlib==0.1.64`).
[(#1924)](https://github.com/PennyLaneAI/pennylane/pull/1924)

<h3>Contributors</h3>

This release contains contributions from (in alphabetical order):

Josh Izaac, Romain Moyard, Antal Száva.
2 changes: 1 addition & 1 deletion pennylane/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.19.0"
__version__ = "0.19.1"
5 changes: 3 additions & 2 deletions pennylane/devices/default_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,9 @@ def _apply_state_vector(self, state, device_wires):
if len(qml.math.shape(state)) != 1 or n_state_vector != 2 ** len(device_wires):
raise ValueError("State vector must be of length 2**wires.")

if not qml.math.is_abstract(state):
if not qml.math.allclose(qml.math.linalg.norm(state, ord=2), 1.0, atol=tolerance):
norm = qml.math.linalg.norm(state, ord=2)
if not qml.math.is_abstract(norm):
if not qml.math.allclose(norm, 1.0, atol=tolerance):
raise ValueError("Sum of amplitudes-squared does not equal one.")

if len(device_wires) == self.num_wires and sorted(device_wires) == device_wires:
Expand Down