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

Installation note in ZNE Catalyst tutorial #1270

Merged
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
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
Loading