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

Minor documentation changes for parameter broadcasting #2736

Merged
merged 3 commits into from
Jun 16, 2022
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
1 change: 1 addition & 0 deletions doc/code/qml_operation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ new :class:`~pennylane.ops.qubit.attributes.Attribute` objects.
~ops.qubit.attributes.diagonal_in_z_basis
~ops.qubit.attributes.has_unitary_generator
~ops.qubit.attributes.self_inverses
~ops.qubit.attributes.supports_broadcasting
~ops.qubit.attributes.symmetric_over_all_wires
~ops.qubit.attributes.symmetric_over_control_wires
9 changes: 1 addition & 8 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
[(#2663)](https://github.com/PennyLaneAI/pennylane/pull/2663)
[(#2684)](https://github.com/PennyLaneAI/pennylane/pull/2684)
[(#2688)](https://github.com/PennyLaneAI/pennylane/pull/2688)

A `reduced_dm` function that can handle both state vectors and density matrix, to return a reduced density matrix:

```pycon
Expand Down Expand Up @@ -303,13 +303,6 @@
0.9905158135644924
```


* Operators have new attributes `ndim_params` and `batch_size`, and `QuantumTapes` have the new
attribute `batch_size`.
- `Operator.ndim_params` contains the expected number of dimensions per parameter of the operator,
- `Operator.batch_size` contains the size of an additional parameter broadcasting axis, if present,
- `QuantumTape.batch_size` contains the `batch_size` of its operations (see below).

* New `solarized_light` and `solarized_dark` styles available for drawing circuit diagram graphics.
[(#2662)](https://github.com/PennyLaneAI/pennylane/pull/2662)

Expand Down
2 changes: 1 addition & 1 deletion pennylane/tape/tape.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ def batch_size(self):
.. seealso:: :attr:`~.Operator.batch_size` for details.

Returns:
int: The batch size of the quantum tape.
int or None: The batch size of the quantum tape if present, else ``None``.
"""
return self._batch_size

Expand Down
8 changes: 3 additions & 5 deletions pennylane/transforms/broadcast_expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def broadcast_expand(tape):
with broadcasting axis of length ``3`` passed to ``qml.RX``:

>>> x = pnp.array([0.2, 0.6, 1.0], requires_grad=True)
>>> qml.draw(expanded_circuit)(x)
>>> print(qml.draw(expanded_circuit)(x))
0: ──RX(0.20)─┤ <Z>
0: ──RX(0.60)─┤ <Z>
0: ──RX(1.00)─┤ <Z>
Expand All @@ -71,13 +71,11 @@ def broadcast_expand(tape):
We also can call the transform manually on a tape:

>>> with qml.tape.QuantumTape() as tape:
>>> qml.RX(np.array([0.2, 0.6, 1.0], requires_grad=True), wires=0)
>>> qml.RX(pnp.array([0.2, 0.6, 1.0], requires_grad=True), wires=0)
>>> qml.expval(qml.PauliZ(0))
>>> tapes, fn = qml.transforms.broadcast_expand(tape)
>>> tapes
[<QuantumTape: wires=[0], params=1>,
<QuantumTape: wires=[0], params=1>,
<QuantumTape: wires=[0], params=1>]
[<QuantumTape: wires=[0], params=1>, <QuantumTape: wires=[0], params=1>, <QuantumTape: wires=[0], params=1>]
>>> fn(qml.execute(tapes, qml.device("default.qubit", wires=1), None))
array([0.98006658, 0.82533561, 0.54030231])
"""
Expand Down