Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 25, 2024
2 parents a2e93b1 + c8b06d8 commit 93c9fec
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 93c9fec

Please sign in to comment.