From 274d868792feb22458d398a36ca0bfccd6856ef8 Mon Sep 17 00:00:00 2001 From: Rebecca Dimock <66339736+beckykd@users.noreply.github.com> Date: Thu, 15 Jun 2023 12:44:06 -0500 Subject: [PATCH] edits (#916) Co-authored-by: Kevin Tian --- docs/tutorials/grover_with_sampler.ipynb | 31 +++++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/docs/tutorials/grover_with_sampler.ipynb b/docs/tutorials/grover_with_sampler.ipynb index b8692ab41..155a04c7e 100644 --- a/docs/tutorials/grover_with_sampler.ipynb +++ b/docs/tutorials/grover_with_sampler.ipynb @@ -1,6 +1,7 @@ { "cells": [ { + "attachments": {}, "cell_type": "markdown", "id": "db78a668", "metadata": {}, @@ -9,25 +10,27 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "e57d1e6b", "metadata": {}, "source": [ "## Background\n", "\n", - "Amplitude amplification is a general purpose quantum algorithm, or subroutine, that can be used to obtain a quadratic speedup over a handful of classical algorithms. [Grover’s algorithm](https://arxiv.org/abs/quant-ph/9605043) was the first to demonstrate this speed up on unstructured search problems. Formulating a Grover's search problem requires an oracle function that marks one or more computational basis states as the states we are interested in finding, and an amplification circuit that increases the amplitude of marked states, consequently suppressing the remaining states. \n", + "Amplitude amplification is a general purpose quantum algorithm, or subroutine, that can be used to obtain a quadratic speedup over a handful of classical algorithms. [Grover’s algorithm](https://arxiv.org/abs/quant-ph/9605043) was the first to demonstrate this speedup on unstructured search problems. Formulating a Grover's search problem requires an oracle function that marks one or more computational basis states as the states we are interested in finding, and an amplification circuit that increases the amplitude of marked states, consequently suppressing the remaining states. \n", "\n", - "Here we demonstrate how to construct Grover oracles and make use of the `GroverOperator` from the Qiskit circuit library, to easily setup a Grover's search instance. The runtime `Sampler` allows for seamless execution of Grover circuits, including automatic compilation, error suppression, and readout error mitigation techniques." + "Here we demonstrate how to construct Grover oracles and make use of the `GroverOperator` from the Qiskit circuit library to easily setup a Grover's search instance. The runtime `Sampler` primitive allows for seamless execution of Grover circuits, including automatic compilation, error suppression, and readout error mitigation techniques." ] }, { + "attachments": {}, "cell_type": "markdown", "id": "54602708", "metadata": {}, "source": [ "## Setup\n", "\n", - "Here we import the small number tools we need for this tutorial." + "Here we import the small number of tools we need for this tutorial." ] }, { @@ -50,13 +53,14 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "f71e0999", "metadata": {}, "source": [ "## Initialize Runtime service and select backends\n", "\n", - "Here we instantiate the Runtime service that gives access to the quantum devices and simulator that we use in this tutorial. Here we make use of a simulator to validate our circuit, and then turn to execution on a real quantum system." + "Here we instantiate the Runtime service that gives access to the quantum devices and the simulator that we use in this tutorial. We will first use a simulator to validate our circuit, then execute it on a real quantum system." ] }, { @@ -81,13 +85,14 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "d4845f4d", "metadata": {}, "source": [ "## Define a Grover experiment\n", "\n", - "Grover's algorithm requires an [oracle](https://quantum-computing.ibm.com/admin/docs/admin/guide/grovers-algorithm#the-oracle) that specifies one or more marked computational basis states, where \"marked\" means a state with a phase of -1. A controlled-Z gate, or its multi-controlled generalization over $N$ qubits, marks the $2^{N}-1$ state (`'1'`*$N$ bit-string). Marking basis states with one or more `'0'` in the binary representation requires applying X-gates on the corresponding qubits before and after the controlled-Z gate; equivalent to having an open-control on that qubit. In the following, we define an oracle that does just that, marking one or more input basis states defined through their bit-string representation. The `MCMT` gate is used to implement the multi-controlled Z-gate." + "Grover's algorithm requires an [oracle](https://quantum-computing.ibm.com/admin/docs/admin/guide/grovers-algorithm#the-oracle) that specifies one or more marked computational basis states, where \"marked\" means a state with a phase of -1. A controlled-Z gate, or its multi-controlled generalization over $N$ qubits, marks the $2^{N}-1$ state (`'1'`*$N$ bit-string). Marking basis states with one or more `'0'` in the binary representation requires applying X-gates on the corresponding qubits before and after the controlled-Z gate; equivalent to having an open-control on that qubit. In the following code, we define an oracle that does just that, marking one or more input basis states defined through their bit-string representation. The `MCMT` gate is used to implement the multi-controlled Z-gate." ] }, { @@ -131,13 +136,14 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "bca14740", "metadata": {}, "source": [ "### Specific Grover's instance\n", "\n", - "With the oracle function in hand, we can now define a specific instance of Grover search. In this example we will mark two computational states out of the 8 available in a 3-qubit computational space:" + "Now that we have the oracle function, we can define a specific instance of Grover search. In this example we will mark two computational states out of the eight available in a three-qubit computational space:" ] }, { @@ -166,13 +172,14 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "25487b93", "metadata": {}, "source": [ "### The `GroverOperator`\n", "\n", - "The built-in Qiskit `GroverOperator` takes an oracle circuit, and returns a circuit that is composed of the oracle circuit itself, and a circuit that amplifies the states marked by the oracle. Here we `decompose` the circuit to see the gates within the operator:" + "The built-in Qiskit `GroverOperator` takes an oracle circuit and returns a circuit that is composed of the oracle circuit itself and a circuit that amplifies the states marked by the oracle. Here, we `decompose` the circuit to see the gates within the operator:" ] }, { @@ -199,6 +206,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "83c34dc9", "metadata": {}, @@ -219,6 +227,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "e06c8238", "metadata": {}, @@ -258,13 +267,14 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "c5edec73", "metadata": {}, "source": [ "## Execution with the Sampler primitive\n", "\n", - "Amplitude amplification is a sampling problem that is suitable for execution with the `Sampler` runtime primitive. Because we have a single-circuit, we instantiate a `Sampler` using the target backend. To begin, this is the simulator:" + "Amplitude amplification is a sampling problem that is suitable for execution with the `Sampler` runtime primitive. Because we have a single circuit, we instantiate a `Sampler` using the target backend. To begin, this is the simulator:" ] }, { @@ -278,11 +288,12 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "618d25bc", "metadata": {}, "source": [ - "and execute the circuit using `sim_sampler.run`. The result is obtained in the returned quasi-probability distribution:" + "Now we execute the circuit by using `sim_sampler.run`. The result is obtained in the returned quasi-probability distribution:" ] }, { @@ -296,6 +307,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "0413c16d", "metadata": {}, @@ -331,6 +343,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "1f53f619", "metadata": {},