Skip to content

Commit

Permalink
RC to master (#2323)
Browse files Browse the repository at this point in the history
* [Bug] Exclude Snapshot from adjoint backwards pass (#2289)

* Exclude Snapshot from adjoint backwards pass

* Add snapshots test for diff_methods

* Changelog

* Trigger rebuild

Co-authored-by: antalszava <antalszava@gmail.com>

* Work on consistency of `Operator`s (#2287)

* some inconsistencies

* swap basis

* undo duplicated wire in test

* changelog

* revert snapshot wires change

* unused import

* merge rc

* revert accidental changelog merge

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Batch run (#2069)

* batching ability for non-trainable inputs only following issue #2037

This function creates multiple circuit executions for batched input examples
and executes all batch inputs with the same trainable variables. The main
difference between the proposed version in the issue and this commit is the
input `argnum` this indicates the location of the given input hence gives the
ability to work across platforms.

* adaptation for batch execution

* improvements according to PR rules

* minor update according to PR errors

* modify according to codefactor-io

* reformatted code style

* adjust line lenght for linting

* update linting

* disable linting for too many arguments

* add testing for batch input in keras

* format test_keras.py

* add tests for remaining functions

* adapt the defaults

* update docstring according to @josh146 's suggestions

* remove keras sterilazation

* add batch_input to the docstring

* docstring update for readability: pennylane/transforms/batch_input.py

Co-authored-by: Josh Izaac <josh146@gmail.com>

* minor fix in documentation

* change assertion error to valueerror

* test valueerror

* modify the definition of argnum

* change argnum -> batch_idx

* update changelog-dev.md

* apply @josh146 's suggestions

* linting

* tests

* more

Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>

* Circuit cutting: Tidy up documentation (#2279)

* Redo imports

* Update docs

* Update wording

* Fix ID

* Add to docs

* Add to docs

* Fix

* Update docstrings

* Use nx.MultiDiGraph

* Update fragment_graph

* Update graph_to_tape

* Update remap_tape_wires

* Rename to expand_fragment_tape

* Update expand_fragment_tape

* Update CutStrategy

* Update qcut_processing_fn

* Remove note

* Update cut_circuit

* Work on docs

* Add to docs

* Update pennylane/transforms/qcut.py

* Add to changelog

* Move device definition

* Mention WireCut

* Move details

* QCut module

* Fix image location

* Fix init

* Apply suggestions from code review

Co-authored-by: anthayes92 <34694788+anthayes92@users.noreply.github.com>

* Add link to communication graph

* Reword

* Move around

* fix

* fix

Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: anthayes92 <34694788+anthayes92@users.noreply.github.com>

* Circuit cutting: update changelog (#2290)

* Redo imports

* Update docs

* Update wording

* Fix ID

* Add to docs

* Add to docs

* Fix

* Update docstrings

* Use nx.MultiDiGraph

* Update fragment_graph

* Update graph_to_tape

* Update remap_tape_wires

* Rename to expand_fragment_tape

* Update expand_fragment_tape

* Update CutStrategy

* Update qcut_processing_fn

* Remove note

* Update cut_circuit

* Work on docs

* Add to docs

* Update pennylane/transforms/qcut.py

* Add to changelog

* Move device definition

* Mention WireCut

* Move details

* QCut module

* Fix image location

* Fix init

* Update changelog

* Link to docs page

* Update wording

* Apply suggestions from code review

Co-authored-by: Josh Izaac <josh146@gmail.com>

* Move

* Update doc/releases/changelog-dev.md

Co-authored-by: Nathan Killoran <co9olguy@users.noreply.github.com>

* Remove

* Update

Co-authored-by: antalszava <antalszava@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Nathan Killoran <co9olguy@users.noreply.github.com>

* Minor gradient fixes (#2299)

* Produce consisten output shapes

In the absence of trainable params, some gradient transforms did not
produce an empty tuple yet like the rest of our functions.

* Minor formatting changes in param_shift_hessian

* Fix param_shift_hessian for all zero diff_methods

* Fix missing requires_grad & catch expected warning

* Changelog

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>

* Deprecate jacobian tape (#2306)

* Deprecate the Jacobian tape

* Deprecate tape subclasses

* changelog

* more test fixes

* tests

* Apply suggestions from code review

Co-authored-by: antalszava <antalszava@gmail.com>

Co-authored-by: antalszava <antalszava@gmail.com>

* `qml.generator` doc fixes (#2309)

* generator doc fixes

* more fixing

* Snapshot: remove temporary fixes for lightning device (#2291)

* Remove temp fixes for lightning

* Include diff_method tests for all devices

* Changelog

* Update CI to use pennylane-lightning dev

Co-authored-by: antalszava <antalszava@gmail.com>

* Docs fixes for v0.22.0 release (#2312)

* Fix Operator docstring hyperrefs

* Fix example for top-level matrix function

* Add example to Snapshot op docstring

* Fix tape drawing examples in docs

* Apply suggestions from code review

* Update pennylane/ops/snapshot.py

Co-authored-by: Christina Lee <christina@xanadu.ai>

* Extend the conditional operations documentation (#2294)

* Add qfunc and else to cond's UsageDetails

* copy when inverting MV under the hood; add equivalent test case for inversion; add err msg when calling == of MV with unexpected typed obj; more examples

* format

* test docstr

* format

* correct examples

* format

* docstring

* have #2300 on rc too

* lambda example

* intro extend, docstring

* changelog PR num

* link

* note update

* updates

* Apply suggestions from code review

* updates

Co-authored-by: Christina Lee <christina@xanadu.ai>

* Add `qml.generator(op)` backwards compatibility (#2305)

* Add qml.generator(op) backwards compatibility

* Apply suggestions from code review

Co-authored-by: David Wierichs <davidwierichs@gmail.com>

* fix docstring

Co-authored-by: David Wierichs <davidwierichs@gmail.com>

* fixed docs

* use better function refs

* pin pennylane-lightning version in CI (#2318)

* Amend docstring examples for `compute_matrix` and `compute_eigvals` (#2314)

* array()

* print() to get the output formatting correct

* revert array()

* print()

Co-authored-by: Maria Schuld <mariaschuld@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>

* Few docstring updates in prep for `v0.22.0` (#2311)

* updates

* - lower

* updates

* contract_tensor ref updates

* rename test file: batch_input

* explicit requires_grad upon param generation

* torch.Tensor as type

* Update pennylane/transforms/__init__.py

Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>

* use tf in example

Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>

* Support for controlled & adjoint in Snapshot/Barrier (#2315)

* controlled, adjoint

* Remove print

* Match adjoint signature of parent class

* Add tests for ctrl/adj support

* Update Barrier.adjoint signature

* Add ctrl test for Barrier

* Update tests/test_debugging.py

* Update tests/ops/test_snapshot.py

* Update tests/ops/test_snapshot.py

* changelog

* trigger build

Co-authored-by: Antal Szava <antalszava@gmail.com>

* ControlledQubitUnitary should raise `DecompositionUndefinedError` (#2320)

* DecompositionUndefinedError

* changelog

* trigger check

* `v0.22.0` release notes (#2303)

* version

* log ref

* rename

* sections; emojis

* format

* improvements order

* format

* addition; collabs; v0.21.0 collab alphabet fix

* reorder

* collab; deprecation item

* more PRs; collab list extended

* update

* sections

* op section break up

* correct matrix example

* suggestions

* suggestions

* a few more

* fix typo in code

* update

* no tf import

* update

Co-authored-by: Josh Izaac <josh146@gmail.com>

* don't pull test Lightning (requires v0.22.0 to land)

* require v0.22 Lightning or higher

* changelog list extend

* update

* Pin Lightning `>=0.22` (#2324)

* pin lightning >=0.22

* Update tests.yml

Co-authored-by: Josh Izaac <josh146@gmail.com>

Co-authored-by: David Ittah <dime10@users.noreply.github.com>
Co-authored-by: David Wierichs <davidwierichs@gmail.com>
Co-authored-by: Josh Izaac <josh146@gmail.com>
Co-authored-by: Jack Y. Araz <jackaraz@gmail.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: anthayes92 <34694788+anthayes92@users.noreply.github.com>
Co-authored-by: Nathan Killoran <co9olguy@users.noreply.github.com>
Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Maria Schuld <mariaschuld@gmail.com>
  • Loading branch information
11 people committed Mar 15, 2022
1 parent 0269f9a commit 15c5b1e
Show file tree
Hide file tree
Showing 78 changed files with 1,666 additions and 968 deletions.
20 changes: 15 additions & 5 deletions doc/development/adding_operators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,35 @@ The basic components of operators are the following:
>>> op.terms()
((1.0, 2.0), [PauliX(wires=[0]), PauliZ(wires=[0])])

* Representation via the **eigenvalue decomposition** specified by eigenvalues (for the diagonal matrix, :meth:`.Operator.eigvals`)
* Representation via the **eigenvalue decomposition** specified by eigenvalues (for the diagonal matrix, :meth:`.Operator.get_eigvals`)
and diagonalizing gates (for the unitaries :meth:`.Operator.diagonalizing_gates`):

>>> op = qml.PauliX(0)
>>> op.diagonalizing_gates()
[Hadamard(wires=[0])]
>>> op.eigvals()
>>> op.get_eigvals()
[ 1 -1]

* Representation as a **matrix** (:meth:`.Operator.matrix`), as specified by a global wire order that tells us where the
.. note::

The :meth:`.Operator.get_eigvals` method is temporary and will be renamed to :meth:`.Operator.eigvals` in an
upcoming release. It is recommended to use the higher-level :func:`~.eigvals` function where possible.

* Representation as a **matrix** (:meth:`.Operator.get_matrix`), as specified by a global wire order that tells us where the
wires are found on a register:

>>> op = qml.PauliRot(0.2, "X", wires=["b"])
>>> op.matrix(wire_order=["a", "b"])
>>> op.get_matrix(wire_order=["a", "b"])
[[9.95e-01-2.26e-18j 2.72e-17-9.98e-02j, 0+0j, 0+0j]
[2.72e-17-9.98e-02j 9.95e-01-2.26e-18j, 0+0j, 0+0j]
[0+0j, 0+0j, 9.95e-01-2.26e-18j 2.72e-17-9.98e-02j]
[0+0j, 0+0j, 2.72e-17-9.98e-02j 9.95e-01-2.26e-18j]]

.. note::

The :meth:`.Operator.get_matrix` method is temporary and will be renamed to :meth:`.Operator.matrix` in an
upcoming release. It is recommended to use the higher-level :func:`~.matrix` function where possible.

* Representation as a **sparse matrix** (:meth:`.Operator.sparse_matrix`):

>>> from scipy.sparse.coo import coo_matrix
Expand Down Expand Up @@ -214,7 +224,7 @@ whether it supports operations using the operation name.
- If the device registers support for an operation with the same name,
PennyLane leaves the gate implementation up to the device. The device
might have a hardcoded implementation, *or* it may refer to one of the
numerical representations of the operator (such as :meth:`.Operator.matrix`).
numerical representations of the operator (such as :meth:`.Operator.get_matrix`).

- If the device does not register support for an operation with the same
name, PennyLane will automatically decompose the gate using :meth:`.Operator.decomposition`.
Expand Down
8 changes: 7 additions & 1 deletion doc/development/guide/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,16 @@ details in the documentation on :doc:`adding operations </development/adding_ope
* Representation as a matrix

>>> op = qml.PauliRot(0.2, "X", wires=["b"])
>>> op.matrix()
>>> op.get_matrix()
[[9.95004177e-01-2.25761781e-18j 2.72169462e-17-9.98334214e-02j]
[2.72169462e-17-9.98334214e-02j 9.95004177e-01-2.25761781e-18j]]

.. note::

The ``op.get_matrix()`` method is temporary and will be renamed to ``op.matrix()`` in an
upcoming release. Where possible it is recommended to use higher-level functions such as
:func:`~.matrix`.

Devices query operators for their properties and representations to
gain information on how to implement the operator.

Expand Down
10 changes: 7 additions & 3 deletions doc/introduction/measurements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ Mid-circuit measurements and conditional operations
---------------------------------------------------

PennyLane allows specifying measurements in the middle of the circuit.
Operations can then be conditioned on the measurement outcome of such
mid-circuit measurements:
Quantum functions such as operations can then be conditioned on the measurement
outcome of such mid-circuit measurements:

.. code-block:: python
Expand All @@ -180,7 +180,7 @@ measurement on qubit 1 yielded ``1`` as an outcome, otherwise doing nothing
for the ``0`` measurement outcome.

PennyLane implements the deferred measurement principle to transform
conditional operations with the :func:`defer_measurements` quantum
conditional operations with the :func:`~.defer_measurements` quantum
function transform.

.. code-block:: python
Expand Down Expand Up @@ -226,6 +226,10 @@ differentiable and device-independent way. Performing true mid-circuit
measurements and conditional operations is dependent on the
quantum hardware and PennyLane device capabilities.

For more examples on applying quantum functions conditionally, refer to the
:func:`~.pennylane.cond` transform.


Changing the number of shots
----------------------------

Expand Down
6 changes: 3 additions & 3 deletions doc/releases/changelog-0.21.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@
This release contains contributions from (in alphabetical order):

Juan Miguel Arrazola, Ali Asadi, Utkarsh Azad, Sam Banning, Thomas Bromley,
Esther Cruz, Christian Gogolin, Nathan Killoran, Christina Lee, Olivia Di
Matteo, Diego Guala, Anthony Hayes, David Ittah, Josh Izaac, Soran Jahangiri,
Edward Jiang, Ankit Khandelwal, Korbinian Kottmann, Romain Moyard, Lee James
Esther Cruz, Olivia Di Matteo, Christian Gogolin, Diego Guala, Anthony Hayes,
David Ittah, Josh Izaac, Soran Jahangiri, Edward Jiang, Ankit Khandelwal,
Nathan Killoran, Korbinian Kottmann, Christina Lee, Romain Moyard, Lee James
O'Riordan, Maria Schuld, Jay Soni, Antal Száva, David Wierichs, Shaoming Zhang.
Loading

0 comments on commit 15c5b1e

Please sign in to comment.