Skip to content

Commit

Permalink
Release notes v0.36 — Error estimation suggestion (#5641)
Browse files Browse the repository at this point in the history
Co-authored-by: trbromley <[email protected]>
Co-authored-by: Thomas R. Bromley <[email protected]>
Co-authored-by: Diksha Dhawan <[email protected]>
Co-authored-by: Diego <[email protected]>
Co-authored-by: Astral Cai <[email protected]>
  • Loading branch information
6 people authored May 3, 2024
1 parent f964d44 commit 0aa8a68
Showing 1 changed file with 49 additions and 26 deletions.
75 changes: 49 additions & 26 deletions doc/releases/changelog-0.36.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,63 @@
[(#5154)](https://github.com/PennyLaneAI/pennylane/pull/5154)
[(#5464)](https://github.com/PennyLaneAI/pennylane/pull/5464)
[(#5465)](https://github.com/PennyLaneAI/pennylane/pull/5465)
[(#5278)](https://github.com/PennyLaneAI/pennylane/pull/5278)
[(#5384)](https://github.com/PennyLaneAI/pennylane/pull/5384)

Focusing on the [spectral norm](https://en.wikipedia.org/wiki/Matrix_norm)
error, it is possible to specify errors in the following operations:
Two new user-facing classes enable calculating and propagating
gate errors in PennyLane:

* For algorithmic-level usecases it is useful to create a custom operation representing a
major building block of the algorithm. This building block can have an error attached but
does not require a decomposition or matrix representation:
* `qml.resource.SpectralNormError`: the spectral norm error is defined as the
distance, in [spectral norm](https://en.wikipedia.org/wiki/Matrix_norm), between
the true unitary we intend to apply and the approximate unitary that is actually applied.

```python
import pennylane as qml
from pennylane.resource.error import ErrorOperation, SpectralNormError
* `qml.resource.ErrorOperation`: a base class that inherits from `qml.operation.Operation`
and represents quantum operations which carry some form of algorithmic error.

`SpectralNormError` can be used for back-of-the-envelope type calculations like obtaining the
spectral norm error between two unitaries via `get_error`:

```python
import pennylane as qml
from pennylane.resource import ErrorOperation, SpectralNormError

intended_op = qml.RY(0.40, 0)
actual_op = qml.RY(0.41, 0) # angle of rotation is slightly off
```

```pycon
>>> SpectralNormError.get_error(intended_op, actual_op)
0.004999994791668309
```

`SpectralNormError` is also a key tool to specify errors in larger quantum circuits:

* For operations representing a major building block of an algorithm, we can create a custom operation
that inherits from `ErrorOperation`. This child class must override the `error` method and
should return a `SpectralNormError` instance:

```python
class MyErrorOperation(ErrorOperation):
def __init__(self, error_val, wires):
self.error_val = error_val
super().__init__(wires=wires)

def error(self):
return SpectralNormError(self.error_val)
```

In this toy example, `MyErrorOperation` introduces an arbitrary `SpectralNormError`
when called in a QNode. It does not require a decomposition or matrix representation
when used with `null.qubit` (suggested for use with resource and error estimation since circuit executions are
not required to calculate resources or errors).

```python
dev = qml.device("null.qubit")

@qml.qnode(dev)
def circuit():
MyErrorOperation(0.1,[0])
MyErrorOperation(0.2,[1])
MyErrorOperation(0.1, wires=0)
MyErrorOperation(0.2, wires=1)
return qml.state()
```

Expand All @@ -46,18 +78,12 @@
{'SpectralNormError': SpectralNormError(0.30000000000000004)}
```

* PennyLane already includes a number of built-in building blocks like
`QuantumPhaseEstimation` and `TrotterProduct`. `TrotterProduct` now
propagates errors based on its input arguments:
the number of steps performed in the Trotter product affects the error estimation.
`QuantumPhaseEstimation` now propagates errors based on the error of its input
unitary.
[(#5278)](https://github.com/PennyLaneAI/pennylane/pull/5278)
[(#5384)](https://github.com/PennyLaneAI/pennylane/pull/5384)
* PennyLane already includes a number of built-in building blocks for algorithms like
`QuantumPhaseEstimation` and `TrotterProduct`. `TrotterProduct` now propagates errors
based on the number of steps performed in the Trotter product. `QuantumPhaseEstimation`
now propagates errors based on the error of its input unitary.

```python
import pennylane as qml

dev = qml.device('null.qubit')
hamiltonian = qml.dot([1.0, 0.5, -0.25], [qml.X(0), qml.Y(0), qml.Z(0)])

Expand All @@ -68,13 +94,15 @@
return qml.state()
```

As above, we can obtain the total spectral norm error of the circuit using `qml.specs`:
Again, the total spectral norm error of the circuit can be calculated using `qml.specs`:

```pycon
>>> qml.specs(circuit)()["errors"]
{'SpectralNormError': SpectralNormError(0.07616666666666666)}
```

Check out our [error propagation demo](https://pennylane.ai/qml/demos/tutorial_error_prop/) to see how to use these new features in a real-world example!

<h4>Access an extended arsenal of quantum algorithms 🏹</h4>

* The Fast Approximate BLock-Encodings (FABLE) algorithm for embedding
Expand Down Expand Up @@ -196,7 +224,6 @@

```python
H = qml.dot([0.1, 0.3, -0.3], [qml.Z(0), qml.Z(1), qml.Z(0) @ qml.Z(2)])

@qml.qnode(qml.device("default.qubit"))
def circuit():
# initialize the eigenvector
Expand Down Expand Up @@ -621,10 +648,6 @@
to see how this can be done.
[(#5339)](https://github.com/PennyLaneAI/pennylane/pull/5339)

* When new operator arithmetic is enabled, `qml.Hamiltonian` is now an alias for `qml.ops.LinearCombination`.
`Hamiltonian` will still be accessible as `qml.ops.Hamiltonian`.
[(#5393)](https://github.com/PennyLaneAI/pennylane/pull/5393)

* Attempting to multiply `PauliWord` and `PauliSentence` with `*` will raise an error. Instead, use `@` to conform with the PennyLane convention.
[(#5341)](https://github.com/PennyLaneAI/pennylane/pull/5341)

Expand Down

0 comments on commit 0aa8a68

Please sign in to comment.