Skip to content

Commit

Permalink
Qchem-ops broadcasting support (#2726)
Browse files Browse the repository at this point in the history
* introduce Operator.ndim_params, Operator.batch_size, QuantumTape.batch_size

* linting

* changelog

* enable tf.function input_signature usage

* black

* test for unsilenced error

* Apply suggestions from code review

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

* introduce device flag and batch_transform for unbroadcasting; use transform in device.batch_transform

* black, [skip ci]

* code review

* string formatting [skip ci]

* operation broadcasting interface tests

* unbroadcast_expand

* tests for expand function

* tests

* black

* compatibility with TensorFlow 2.6

* builtins unstack

* failing case coverage

* stop using I in operation.py [skip ci]

* commit old changes

* Apply suggestions from code review

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

* intermed

* review

* Apply suggestions from code review

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

* review [skip ci]

* move changelog section from "improvements" to "new features"

* changelog

* add missing files

* clean up, move broadcast dimension first

* namespace

* linting variable names

* update tests that manually set ndim_params for default ops

* pin protobuf<4.21.0

* improve shape coersion order

* first features

* fix sample selection

* pin protobuf<4.21.0

* changelog formatting

* more testing, better batch_size

* fix tf function batch_size

* broadcasted pow tests

* attribute test, ControlledQubitUnitary update

* more tf support

* test kwargs attributes

* Apply suggestions from code review

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

* changelog

* review

* remove prints

* explicit attribute supports_broadcasting tests

* tests disentangle

* fix

* PauliRot broadcasted identity compatible with TF

* rename "batched" into "broadcasted" for uniform namespace

* old TF version support in qubitunitary unitarity check

* python3.7 support

* extend support, flip flag

* fix _apply_unitary when applying unbroadcasted operator to broadcasted state

* tests default_qubit

* speed up _get_batch_size by a factor 10

* [skip ci] ndim adaptation, fix dimension in _get_bathc_size call

* default qubit additional broadcasting support

* default_qubit broadcasted tests start

* most of test suite

* black

* complete default qubit tests (without interfaces)

* tmp autograd done, jax partially

* tf tests

* testing

* black

* linting

* tests

* black

* tf fix

* minor changes

* use get_batch_size

* some TF tests

* tf test finished

* torch tests

* changelog

* move _get_batch_size to DefaultQubit, give QubitDevice dummy _get_batch_size, tests

* linting, old tf version support

* test coverage

* test fix

* mark jax test

* self- review

* Apply suggestions from code review

* typo

* changelog example

* speedup par ops

* qchem matrices

* parametric ops eigvals

* linting

* lint

* changelog

* id addition

* isingxy

* isingxy tests

* black

* mention speedup in changelog

* singleexcitation fix

* add ndim_params properties and add qchem ops to attribute

* attribute and test

* Revert "merge"

This reverts commit 55cb10d, reversing
changes made to 1cac187.

* mask lookups

* black

* remove unnecessary eigvals

* remove speedups to put them in separate PR

* tmp

* converged matrix methods, priority for scalar speedups

* black

* lint

* exclude isingxy changes (duplicate from #2759)

* revert generator changes

* dtype namespace

* unfying functions for qchem compute_matrix methods in Single- and DoubleExcitations

* black

Co-authored-by: Josh Izaac <josh146@gmail.com>
  • Loading branch information
dwierichs and josh146 authored Aug 3, 2022
1 parent 24a0d9a commit f3005be
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 112 deletions.
18 changes: 16 additions & 2 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@

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

* Operations for quantum chemistry now also support parameter broadcasting
in their numerical representations.
[(#2726)](https://github.com/PennyLaneAI/pennylane/pull/2726)

Similar to standard parametrized operations, quantum chemistry operations now
also work with broadcasted parameters:

```pycon
>>> op = qml.SingleExcitation(np.array([0.3, 1.2, -0.7]), wires=[0, 1])
>>> op.matrix().shape
(3, 4, 4)
```

* The gradient transform `qml.gradients.param_shift` now accepts the new Boolean keyword
argument `broadcast`. If it is set to `True`, broadcasting is used to compute the derivative.
[(#2749)](https://github.com/PennyLaneAI/pennylane/pull/2749)
Expand Down Expand Up @@ -259,8 +272,9 @@
>>> relative_entropy_circuit((x,), (y,))
0.017750012490703237
```

* New PennyLane-inspired `sketch` and `sketch_dark` styles are now available for drawing circuit diagram graphics.

* New PennyLane-inspired `sketch` and `sketch_dark` styles are now available for
drawing circuit diagram graphics.
[(#2709)](https://github.com/PennyLaneAI/pennylane/pull/2709)

* Added `QutritDevice` as an abstract base class for qutrit devices.
Expand Down
7 changes: 7 additions & 0 deletions pennylane/ops/qubit/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ def __contains__(self, obj):
"IsingYY",
"IsingZZ",
"IsingXY",
"SingleExcitation",
"SingleExcitationPlus",
"SingleExcitationMinus",
"DoubleExcitation",
"DoubleExcitationPlus",
"DoubleExcitationMinus",
"OrbitalRotation",
]
)
"""Attribute: Operations that support parameter broadcasting.
Expand Down
Loading

0 comments on commit f3005be

Please sign in to comment.