Skip to content

Commit

Permalink
Installation note in ZNE Catalyst tutorial (#1270)
Browse files Browse the repository at this point in the history
Follow-up of [#1207](#1207) to
add a note on plugin installation.
[As per @dedoussis's feedback 🙏]

---------

Co-authored-by: Ivana Kurečić <[email protected]>
  • Loading branch information
cosenal and ikurecic authored Nov 25, 2024
1 parent 9b70c40 commit c8b06d8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion demonstrations/tutorial_zne_catalyst.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
],
"dateOfPublication": "2024-11-15T00:00:00+00:00",
"dateOfLastModification": "2024-11-15T00:00:00+00:00",
"dateOfLastModification": "2024-11-25T09:00:00+00:00",
"categories": [
"Algorithms",
"Quantum Computing"
Expand Down
34 changes: 23 additions & 11 deletions demonstrations/tutorial_zne_catalyst.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,29 @@
These three stages illustrate what happens behind the scenes when using a ZNE routine.
However, from the user's perspective, one only needs to define the initial circuit,
the noise scaling method, and the extrapolation method. The rest is taken care of by Catalyst.
Defining the mirror circuit
---------------------------
The first step for demoing an error mitigation routine is to define a circuit.
Here we build a simple mirror circuit starting off a `unitary 2-design <https://en.wikipedia.org/wiki/Quantum_t-design>`__.
This is a typical construction for a randomized benchmarking circuit, which is used in many tasks
in quantum computing. Given such circuit, we measure the expectation value :math:`\langle Z\rangle`
on the state of the first qubit, and by construction of the circuit, we expect this value to be
equal to 1.
"""

import timeit
##############################################################################
# .. note ::
#
# To follow along with this demonstration, it is required to
# `install Catalyst <https://docs.pennylane.ai/projects/catalyst/en/stable/dev/installation.html>`__,
# as well as the `PennyLane-Qrack plugin <https://pennylane-qrack.readthedocs.io/en/latest/installation.html>`__.
#
# .. code-block:: bash
#
# pip install -U pennylane-catalyst pennylane-qrack
#

##############################################################################
# Defining the mirror circuit
# ---------------------------
# The first step for demoing an error mitigation routine is to define a circuit.
# Here we build a simple mirror circuit starting off a `unitary 2-design <https://en.wikipedia.org/wiki/Quantum_t-design>`__.
# This is a typical construction for a randomized benchmarking circuit, which is used in many tasks
# in quantum computing. Given such circuit, we measure the expectation value :math:`\langle Z\rangle`
# on the state of the first qubit, and by construction of the circuit, we expect this value to be
# equal to 1.

import numpy as np
import pennylane as qml
Expand Down Expand Up @@ -214,6 +224,8 @@ def mitigated_circuit(w1, w2):
# Note: for the purpose of this last example, we reduce the number of shots of the simulator to 100,
# since we don't need the accuracy required for the previous demonstration. We do so in order to
# reduce the running time of this tutorial, while still showcasing the performance differences.
import timeit

noisy_device = qml.device("qrack.simulator", n_wires, shots=100, noise=NOISE_LEVEL)
noisy_qnode = qml.QNode(circuit, device=noisy_device, mcm_method="one-shot")

Expand Down

0 comments on commit c8b06d8

Please sign in to comment.