From 025f1c704aae4fc4a2682f34590bded86c372b6f Mon Sep 17 00:00:00 2001 From: Nathan Killoran Date: Tue, 16 Jun 2020 14:08:44 -0400 Subject: [PATCH 1/7] Update CHANGELOG.md --- .github/CHANGELOG.md | 105 +++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 383b37fe9fd..c5c69c4881e 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -2,9 +2,11 @@

New features since last release

-* Adds a new device, `default.qubit.tf`, a pure-state qubit simulator written using TensorFlow. +

New and improved simulators

+ +* Added a new device, `default.qubit.tf`, a pure-state qubit simulator written using TensorFlow. As a result, it supports classical backpropagation as a means to compute the Jacobian. This can - be faster than the parameter-shift rule for analytic quantum gradients + be faster than the parameter-shift rule for computing quantum gradients when the number of parameters to be optimized is large. `default.qubit.tf` is designed to be used with end-to-end classical backpropagation @@ -34,10 +36,15 @@ [documentation](https://pennylane.ai/en/stable/code/api/pennylane.beta.plugins.DefaultQubitTF.html) for more details. -* Contains the new template `UCCSD` implementing the Unitary Coupled-Cluster (UCCSD) ansatz - to perform VQE-based quantum chemistry simulations using PennyLane-QChem. - [(#654)](https://github.com/XanaduAI/pennylane/pull/654) - +* The ``default.tensor`` plugin has been significantly upgraded. It now allows two different + tensor network representations to be used: `"exact"` and `"mps"`. The former uses a + exact factorized representation of quantum states, while the latter uses a matrix product state + representation. + ([#572](https://github.com/XanaduAI/pennylane/pull/572)) + ([#599](https://github.com/XanaduAI/pennylane/pull/599)) + +

New machine learning functionality and integrations

+ * PennyLane QNodes can now be converted into Torch layers, allowing for creation of quantum and hybrid models using the `torch.nn` API. [(#588)](https://github.com/XanaduAI/pennylane/pull/588) @@ -53,7 +60,7 @@ weight_shapes = {"weights_0": 3, "weight_1": 1} qlayer = qml.qnn.TorchLayer(qnode, weight_shapes) ``` - + A hybrid model can then be easily constructed: ```python @@ -62,65 +69,29 @@ * Added a new "reversible" differentiation method which can be used in simulators, but not hardware. The reversible approach is similar to backpropagation, but trades off extra computation for enhanced memory efficiency. Where backpropagation caches the state tensors at each step during - a forward pass, the reversible method only caches the final pre-measurement state. Compared to + a simulated evolution, the reversible method only caches the final pre-measurement state. Compared to the parameter-shift method, the reversible method can be faster or slower, depending on the density and location of parametrized gates in a circuit (circuits with higher density of parametrized gates near the end of the circuit will see a benefit). [(#670)](https://github.com/XanaduAI/pennylane/pull/670) + +

New templates and cost functions

-* Contains the new template `DoubleExcitationUnitary` implementing the quantum circuit to - exponentiate the Coupled-Cluster double excitation operator. This template is required to - build the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz for VQE simulations. +* Added the new templates `UCCSD`, `SingleExcitationUnitary`, and`DoubleExcitationUnitary`, + which together implement the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz + to perform VQE-based quantum chemistry simulations using PennyLane-QChem. + [(#654)](https://github.com/XanaduAI/pennylane/pull/654) [(#638)](https://github.com/XanaduAI/pennylane/pull/638) [(#659)](https://github.com/XanaduAI/pennylane/pull/659) - -* Contains the new template `SingleExcitationUnitary` implementing the quantum circuit to - exponentiate the Coupled-Cluster single excitation operator. This template is required to - build the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz for VQE simulations. [(#622)](https://github.com/XanaduAI/pennylane/pull/622) - [(#659)](https://github.com/XanaduAI/pennylane/pull/659) -* Added module `pennylane.qnn.cost` with class `SquaredErrorLoss`. The module will contain classes - to calculate losses and costs on circuits with trainable parameters. +* Added module `pennylane.qnn.cost` with class `SquaredErrorLoss`. The module contains classes + to calculate losses and cost functions on circuits with trainable parameters. [(#642)](https://github.com/XanaduAI/pennylane/pull/642) -* The ``default.tensor`` plugin has been significantly upgraded. It now allows two different - tensor network representations to be used: `"exact"` and `"mps"`. The former uses a - exact factorized representation of quantum states, while the latter uses a matrix product state - representation. - ([#572](https://github.com/XanaduAI/pennylane/pull/572)) - ([#599](https://github.com/XanaduAI/pennylane/pull/599)) -

Improvements

-* Adds `decomposition` method to PauliX, PauliY, PauliZ, S, T, Hadamard, and PhaseShift gates, which - decomposes each of these gates into rotation gates. - [(#668)](https://github.com/XanaduAI/pennylane/pull/668) - -* The `CircuitGraph` class now supports serializing contained circuit operations - and measurement basis rotations to an OpenQASM2.0 script via the new - `CircuitGraph.to_openqasm()` method. - [(#623)](https://github.com/XanaduAI/pennylane/pull/623) - -* The QNode Torch interface now inspects QNode positional arguments. - If any argument does not have the attribute `requires_grad=True`, it - is automatically excluded from quantum gradient computations. - [(#652)](https://github.com/XanaduAI/pennylane/pull/652) - [(#660)](https://github.com/XanaduAI/pennylane/pull/660) - -* The QNode TF interface now inspects QNode positional arguments. - If any argument is not being watched by a `tf.GradientTape()`, - it is automatically excluded from quantum gradient computations. - [(#655)](https://github.com/XanaduAI/pennylane/pull/655) - [(#660)](https://github.com/XanaduAI/pennylane/pull/660) - -* QNodes have two new public methods: `QNode.set_trainable_args()` and `QNode.get_trainable_args()`. - These are designed to be called by interfaces, to specify to the QNode which of its - input arguments are differentiable. Arguments which are non-differentiable will not be converted - to PennyLane Variable objects within the QNode. - [(#660)](https://github.com/XanaduAI/pennylane/pull/660) - -* A significant refactor with respect to how QNodes and interfaces mark quantum function +* A significant improvement with respect to how QNodes and interfaces mark quantum function arguments as differentiable when using Autograd, designed to improve performance and make QNodes more intuitive. [(#648)](https://github.com/XanaduAI/pennylane/pull/648) @@ -141,12 +112,40 @@ The ability to pass `argnum` has been retained for backwards compatibility, and if present the old behaviour persists. +* The QNode Torch interface now inspects QNode positional arguments. + If any argument does not have the attribute `requires_grad=True`, it + is automatically excluded from quantum gradient computations. + [(#652)](https://github.com/XanaduAI/pennylane/pull/652) + [(#660)](https://github.com/XanaduAI/pennylane/pull/660) + +* The QNode TF interface now inspects QNode positional arguments. + If any argument is not being watched by a `tf.GradientTape()`, + it is automatically excluded from quantum gradient computations. + [(#655)](https://github.com/XanaduAI/pennylane/pull/655) + [(#660)](https://github.com/XanaduAI/pennylane/pull/660) + +* QNodes have two new public methods: `QNode.set_trainable_args()` and `QNode.get_trainable_args()`. + These are designed to be called by interfaces, to specify to the QNode which of its + input arguments are differentiable. Arguments which are non-differentiable will not be converted + to PennyLane Variable objects within the QNode. + [(#660)](https://github.com/XanaduAI/pennylane/pull/660) + +* Added `decomposition` method to PauliX, PauliY, PauliZ, S, T, Hadamard, and PhaseShift gates, which + decomposes each of these gates into rotation gates. + [(#668)](https://github.com/XanaduAI/pennylane/pull/668) + +* The `CircuitGraph` class now supports serializing contained circuit operations + and measurement basis rotations to an OpenQASM2.0 script via the new + `CircuitGraph.to_openqasm()` method. + [(#623)](https://github.com/XanaduAI/pennylane/pull/623) +

Breaking changes

* Removes support for Python 3.5. [(#639)](https://github.com/XanaduAI/pennylane/pull/639)

Documentation

+* Various small typos were fixed.

Bug fixes

From 4ae34234a95225df32abd0ae316919129eba08aa Mon Sep 17 00:00:00 2001 From: Nathan Killoran Date: Wed, 17 Jun 2020 11:18:05 -0400 Subject: [PATCH 2/7] Apply suggestions from code review Co-authored-by: Josh Izaac --- .github/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index c5c69c4881e..c30b355bc8c 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -80,8 +80,9 @@ * Added the new templates `UCCSD`, `SingleExcitationUnitary`, and`DoubleExcitationUnitary`, which together implement the Unitary Coupled-Cluster Singles and Doubles (UCCSD) ansatz to perform VQE-based quantum chemistry simulations using PennyLane-QChem. - [(#654)](https://github.com/XanaduAI/pennylane/pull/654) + [(#622)](https://github.com/XanaduAI/pennylane/pull/622) [(#638)](https://github.com/XanaduAI/pennylane/pull/638) + [(#654)](https://github.com/XanaduAI/pennylane/pull/654) [(#659)](https://github.com/XanaduAI/pennylane/pull/659) [(#622)](https://github.com/XanaduAI/pennylane/pull/622) From fbfda07406159e7c80fbc0ee14fc115571c98d7c Mon Sep 17 00:00:00 2001 From: Nathan Killoran Date: Wed, 17 Jun 2020 11:20:10 -0400 Subject: [PATCH 3/7] Update .github/CHANGELOG.md --- .github/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index c30b355bc8c..7dba773efda 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -36,7 +36,7 @@ [documentation](https://pennylane.ai/en/stable/code/api/pennylane.beta.plugins.DefaultQubitTF.html) for more details. -* The ``default.tensor`` plugin has been significantly upgraded. It now allows two different +* The [``default.tensor`` plugin](https://github.com/XanaduAI/pennylane/blob/master/pennylane/beta/plugins/default_tensor.py) has been significantly upgraded. It now allows two different tensor network representations to be used: `"exact"` and `"mps"`. The former uses a exact factorized representation of quantum states, while the latter uses a matrix product state representation. From 2698a0c80bf7507a3eb0e271cde8a2153b933e25 Mon Sep 17 00:00:00 2001 From: Nathan Killoran Date: Wed, 17 Jun 2020 11:25:31 -0400 Subject: [PATCH 4/7] Update CHANGELOG.md --- .github/CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 7dba773efda..98a034b23ea 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -75,6 +75,18 @@ parametrized gates near the end of the circuit will see a benefit). [(#670)](https://github.com/XanaduAI/pennylane/pull/670) + ```pycon + >>> dev = qml.device("default.qubit", wires=2) + ... @qml.qnode(dev, diff_method="reversible") + ... def circuit(x): + ... qml.RX(x, wires=0) + ... qml.RX(x, wires=0) + ... qml.CNOT(wires=[0,1]) + ... return qml.expval(qml.PauliZ(0)) + >>> qml.grad(circuit)(0.5, 1.2) + (array(-0.47942554),) + ``` +

New templates and cost functions

* Added the new templates `UCCSD`, `SingleExcitationUnitary`, and`DoubleExcitationUnitary`, From fec6650357a5fa1e37562ef4f52dcbbdfe4cad34 Mon Sep 17 00:00:00 2001 From: Nathan Killoran Date: Wed, 17 Jun 2020 11:25:49 -0400 Subject: [PATCH 5/7] Update .github/CHANGELOG.md --- .github/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 98a034b23ea..d2329f3d3ff 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -83,7 +83,7 @@ ... qml.RX(x, wires=0) ... qml.CNOT(wires=[0,1]) ... return qml.expval(qml.PauliZ(0)) - >>> qml.grad(circuit)(0.5, 1.2) + >>> qml.grad(circuit)(0.5) (array(-0.47942554),) ``` From cecd323f2172f60baff70127ed1150c4c0145f95 Mon Sep 17 00:00:00 2001 From: Nathan Killoran Date: Wed, 17 Jun 2020 11:28:15 -0400 Subject: [PATCH 6/7] Update CHANGELOG.md --- .github/CHANGELOG.md | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index d2329f3d3ff..9724baf9a4b 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -51,28 +51,30 @@ A PennyLane QNode can be converted into a `torch.nn` layer using the `qml.qnn.TorchLayer` class: - ```python - @qml.qnode(dev) - def qnode(inputs, weights_0, weight_1): - # define the circuit - # ... + ```pycon + >>> @qml.qnode(dev) + ... def qnode(inputs, weights_0, weight_1): + ... # define the circuit + ... # ... - weight_shapes = {"weights_0": 3, "weight_1": 1} - qlayer = qml.qnn.TorchLayer(qnode, weight_shapes) + >>> weight_shapes = {"weights_0": 3, "weight_1": 1} + >>> qlayer = qml.qnn.TorchLayer(qnode, weight_shapes) ``` A hybrid model can then be easily constructed: - ```python - model = torch.nn.Sequential(qlayer, torch.nn.Linear(2, 2)) + ```pycon + >>> model = torch.nn.Sequential(qlayer, torch.nn.Linear(2, 2)) ``` * Added a new "reversible" differentiation method which can be used in simulators, but not hardware. + The reversible approach is similar to backpropagation, but trades off extra computation for enhanced memory efficiency. Where backpropagation caches the state tensors at each step during - a simulated evolution, the reversible method only caches the final pre-measurement state. Compared to - the parameter-shift method, the reversible method can be faster or slower, depending on the - density and location of parametrized gates in a circuit (circuits with higher density of - parametrized gates near the end of the circuit will see a benefit). + a simulated evolution, the reversible method only caches the final pre-measurement state. + + Compared to the parameter-shift method, the reversible method can be faster or slower, + depending on the density and location of parametrized gates in a circuit + (circuits with higher density of parametrized gates near the end of the circuit will see a benefit). [(#670)](https://github.com/XanaduAI/pennylane/pull/670) ```pycon From 4adf4f4a4f83994776516ccde8cec830aa5789d8 Mon Sep 17 00:00:00 2001 From: Nathan Killoran Date: Thu, 18 Jun 2020 09:26:28 -0400 Subject: [PATCH 7/7] Update .github/CHANGELOG.md Co-authored-by: Josh Izaac --- .github/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 9724baf9a4b..aba84b409fd 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -36,7 +36,7 @@ [documentation](https://pennylane.ai/en/stable/code/api/pennylane.beta.plugins.DefaultQubitTF.html) for more details. -* The [``default.tensor`` plugin](https://github.com/XanaduAI/pennylane/blob/master/pennylane/beta/plugins/default_tensor.py) has been significantly upgraded. It now allows two different +* The [default.tensor plugin](https://github.com/XanaduAI/pennylane/blob/master/pennylane/beta/plugins/default_tensor.py) has been significantly upgraded. It now allows two different tensor network representations to be used: `"exact"` and `"mps"`. The former uses a exact factorized representation of quantum states, while the latter uses a matrix product state representation.