Skip to content

Commit

Permalink
Daily rc sync to master 2022-08-09 (#2914)
Browse files Browse the repository at this point in the history
* Update the Hermiticity check of `qml.Hermitian` to use `qml.math` (#2895)

* fix

* changelog

* lint

* important typo fix (#2901)

* test lightning (#2903)

* Update the readme and PennyLane Logo (#2912)

* Update PennyLane Logo

* remove wordmark from readme

* update citation

* et al

* Update the logo

* replace with svg

* exclude files from pr

Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: David Wierichs <davidwierichs@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: GitHub Actions Bot <>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
  • Loading branch information
5 people committed Aug 9, 2022
1 parent 3707007 commit a02bdbc
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 206 deletions.
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<p align="center">
<a href="https://pennylane.ai">
<img width=80% src="https://raw.githubusercontent.com/PennyLaneAI/pennylane/master/doc/_static/pennylane_thin.png">
</a>
</p>

<p align="center">
<!-- Tests (GitHub actions) -->
<a href="https://github.com/PennyLaneAI/pennylane/actions?query=workflow%3ATests">
Expand Down Expand Up @@ -147,10 +141,8 @@ PennyLane is the work of [many contributors](https://github.com/PennyLaneAI/penn

If you are doing research using PennyLane, please cite [our paper](https://arxiv.org/abs/1811.04968):

> Ville Bergholm, Josh Izaac, Maria Schuld, Christian Gogolin, M. Sohaib Alam, Shahnawaz Ahmed,
> Juan Miguel Arrazola, Carsten Blank, Alain Delgado, Soran Jahangiri, Keri McKiernan, Johannes Jakob Meyer,
> Zeyue Niu, Antal Száva, and Nathan Killoran.
> *PennyLane: Automatic differentiation of hybrid quantum-classical computations.* 2018. arXiv:1811.04968
> Ville Bergholm et al. *PennyLane: Automatic differentiation of hybrid quantum-classical
> computations.* 2018. arXiv:1811.04968
## License

Expand Down
Binary file removed doc/_static/building_blocks.png
Binary file not shown.
Binary file modified doc/_static/favicon.ico
Binary file not shown.
Binary file modified doc/_static/header-dark-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/_static/header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed doc/_static/intro.png
Binary file not shown.
Binary file modified doc/_static/jigsaw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/_static/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed doc/_static/numpy.jpeg
Binary file not shown.
Binary file removed doc/_static/pennylane.png
Binary file not shown.
230 changes: 63 additions & 167 deletions doc/_static/pennylane.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed doc/_static/pennylane_big.png
Binary file not shown.
Binary file removed doc/_static/pennylane_thin.png
Binary file not shown.
Binary file modified doc/_static/pl_wordmark.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@

# Xanadu theme options (see theme.conf for more information).
html_theme_options = {
"navbar_wordmark_path": "_static/pl_wordmark.png",
"navbar_logo_path": "_static/logo.png",
"navbar_wordmark_path": "_static/pennylane.svg",
# Specifying #19b37b is more correct but does not match the other PL websites.
"navbar_logo_colour": "#2d7c7f",
"navbar_home_link": "https://pennylane.ai",
Expand Down
8 changes: 3 additions & 5 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,9 @@ If you are doing research using PennyLane, please cite

.. rst-class:: admonition warning

Ville Bergholm, Josh Izaac, Maria Schuld, Christian Gogolin, M. Sohaib Alam, Shahnawaz Ahmed,
Juan Miguel Arrazola, Carsten Blank, Alain Delgado, Soran Jahangiri, Keri McKiernan, Johannes Jakob Meyer,
Zeyue Niu, Antal Száva, and Nathan Killoran.
*PennyLane: Automatic differentiation of hybrid quantum-classical computations.* 2018.
`arXiv:1811.04968 <https://arxiv.org/abs/1811.04968>`_
Ville Bergholm et al. *PennyLane: Automatic differentiation of hybrid
quantum-classical computations.* 2018. `arXiv:1811.04968
<https://arxiv.org/abs/1811.04968>`_

Support and contribution
------------------------
Expand Down
7 changes: 6 additions & 1 deletion doc/releases/changelog-0.25.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ of operators.
1. The custom device inherits from `DefaultQubit`, not `QubitDevice`.
2. The device implements custom methods in the simulation pipeline that are incompatible
with broadcasting (for example `expval`, `apply_operation` or `analytic_probability`).
3. The custom device maintains the flag `"supports_broadcasting": False` in its `capabilities`
3. The custom device maintains the flag `"supports_broadcasting": True` in its `capabilities`
dictionary *or* it overwrites `Device.batch_transform` without applying `broadcast_expand`
(or both).

Expand Down Expand Up @@ -700,6 +700,11 @@ of operators.

<h3>Bug fixes 🐞</h3>

* Reworked the Hermiticity check in `qml.Hermitian` by using `qml.math` calls
because calling `.conj()` on an `EagerTensor` from TensorFlow raised an
error.
[(#2895)](https://github.com/PennyLaneAI/pennylane/pull/2895)

* Updated IsingXY gate docstring.
[(#2858)](https://github.com/PennyLaneAI/pennylane/pull/2858)

Expand Down
8 changes: 5 additions & 3 deletions pennylane/ops/qubit/observables.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
excepting the Pauli gates and Hadamard gate in ``non_parametric_ops.py``.
"""

from scipy.sparse import csr_matrix
from copy import copy

import numpy as np
from scipy.sparse import csr_matrix

import pennylane as qml
from pennylane.operation import AllWires, AnyWires, Observable
from pennylane.wires import Wires

from .matrix_ops import QubitUnitary


Expand Down Expand Up @@ -93,7 +95,7 @@ def compute_matrix(A): # pylint: disable=arguments-differ
if A.shape[0] != A.shape[1]:
raise ValueError("Observable must be a square matrix.")

if not qml.math.allclose(A, A.conj().T):
if not qml.math.allclose(A, qml.math.T(qml.math.conj(A))):
raise ValueError("Observable must be Hermitian.")

return A
Expand Down Expand Up @@ -458,4 +460,4 @@ def compute_diagonalizing_gates(
return []

def pow(self, z):
return [self.__copy__()] if (isinstance(z, int) and z > 0) else super().pow(z)
return [copy(self)] if (isinstance(z, int) and z > 0) else super().pow(z)
16 changes: 16 additions & 0 deletions tests/devices/test_default_qubit_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,22 @@ def circuit(x, w=None):
):
qml.qnode(dev, diff_method="backprop", interface=interface)(circuit)

def test_hermitian_backprop(self, tol):
"""Test that backprop with qml.Hermitian works correctly"""
dev = qml.device("default.qubit.tf", wires=2)

K = tf.linalg.diag([1, 2, 3, 4])

@qml.qnode(dev, interface="tf", diff_method="backprop")
def circuit(op):
qml.PauliX(0)
qml.PauliX(1)
return qml.expval(op)

res = circuit(qml.Hermitian(K, wires=range(2)))
assert isinstance(res, tf.Tensor)
assert res == 4.0


@pytest.mark.tf
class TestSamples:
Expand Down
38 changes: 19 additions & 19 deletions tests/returntypes/test_new_return_types_qnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import pennylane as qml

wires = [2, 3, 4]
devices = ["default.qubit", "default.mixed"]
devices = ["default.qubit", "lightning.qubit", "default.mixed"]


class TestIntegrationSingleReturn:
Expand All @@ -36,7 +36,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.state()

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == (2**wires,)
Expand All @@ -52,7 +52,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.state()

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == (2**wires, 2**wires)
Expand All @@ -69,7 +69,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.density_matrix(wires=range(0, d_wires))

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == (2**d_wires, 2**d_wires)
Expand All @@ -85,7 +85,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.expval(qml.PauliZ(wires=1))

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == ()
Expand All @@ -101,7 +101,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.var(qml.PauliZ(wires=1))

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == ()
Expand All @@ -117,7 +117,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.vn_entropy(wires=0)

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == ()
Expand All @@ -133,7 +133,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.mutual_info(wires0=[0], wires1=[1])

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert res.shape == ()
Expand All @@ -158,7 +158,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.probs(op=op, wires=wires)

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

if wires is None:
Expand Down Expand Up @@ -246,7 +246,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.state()

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(tf.Variable(0.5))

assert res.shape == (2**wires, 2**wires)
Expand Down Expand Up @@ -461,7 +461,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.state()

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(torch.tensor(0.5, requires_grad=True))

assert res.shape == (2**wires, 2**wires)
Expand Down Expand Up @@ -675,7 +675,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.state()

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(jax.numpy.array(0.5))

assert res.shape == (2**wires, 2**wires)
Expand Down Expand Up @@ -854,7 +854,7 @@ def circuit(x):

wires = [([0], [1]), ([1], [0]), ([0], [0]), ([1], [1])]

devices = ["default.qubit", "default.mixed"]
devices = ["default.qubit", "lightning.qubit", "default.mixed"]


class TestIntegrationMultipleReturns:
Expand All @@ -872,7 +872,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.expval(qml.Projector([0], wires=0)), qml.expval(qml.PauliZ(wires=1))

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert isinstance(res, tuple)
Expand All @@ -894,7 +894,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.var(qml.PauliZ(wires=0)), qml.var(qml.Hermitian([[1, 0], [0, 1]], wires=1))

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert isinstance(res, tuple)
Expand Down Expand Up @@ -929,7 +929,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.probs(op=op1, wires=wires1), qml.probs(op=op2, wires=wires2)

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert isinstance(res, tuple)
Expand Down Expand Up @@ -964,7 +964,7 @@ def circuit(x):
qml.expval(qml.PauliZ(wires=wires4)),
)

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

if wires1 is None:
Expand Down Expand Up @@ -1045,7 +1045,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return [qml.expval(qml.PauliZ(wires=0))]

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

assert isinstance(res, list)
Expand Down Expand Up @@ -2354,7 +2354,7 @@ def circuit(x):
qml.CRX(x, wires=[0, 1])
return qml.apply(meas1), qml.apply(meas2)

qnode = qml.QNode(circuit, dev)
qnode = qml.QNode(circuit, dev, diff_method=None)
res = qnode(0.5)

all_shots = sum([shot_tuple.copies for shot_tuple in dev.shot_vector])
Expand Down

0 comments on commit a02bdbc

Please sign in to comment.