From b29ccb6bfe6033cbde5d64d597f72a889dcfab38 Mon Sep 17 00:00:00 2001 From: Mariia Mykhailova Date: Tue, 18 Aug 2020 08:50:54 -0700 Subject: [PATCH] Several maintenance fixes (#461) * Skip 5 least frequently used on Binder katas in Docker image prebuild to speed up Binder image build * Fix links to docs on controlled functor * In notebooks, update qsharp version (in metadata) to 0.12 * [SingleQubitGates] Add some simple properties of Pauli gates --- .github/CONTRIBUTING.md | 2 +- BasicGates/BasicGates.ipynb | 6 ++--- .../DeutschJozsaAlgorithm.ipynb | 19 ++++++++-------- Dockerfile | 11 +++++----- GraphColoring/GraphColoring.ipynb | 2 +- GroversAlgorithm/GroversAlgorithm.ipynb | 2 +- QEC_BitFlipCode/QEC_BitFlipCode.ipynb | 2 +- RippleCarryAdder/RippleCarryAdder.ipynb | 2 +- SuperdenseCoding/SuperdenseCoding.ipynb | 2 +- Teleportation/Teleportation.ipynb | 2 +- .../ExploringGroversAlgorithmTutorial.ipynb | 2 +- .../MultiQubitGates/MultiQubitGates.ipynb | 2 +- .../MultiQubitSystems/MultiQubitSystems.ipynb | 2 +- tutorials/Qubit/Qubit.ipynb | 2 +- .../SingleQubitGates/SingleQubitGates.ipynb | 22 +++++++++++++++---- 15 files changed, 48 insertions(+), 32 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 7163e27a..e1bab369 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -118,7 +118,7 @@ and to [have PowerShell installed](https://github.com/PowerShell/PowerShell#get- 2. **Running on Binder** The Katas can be run online on [Binder](https://mybinder.org); when you make a potentially breaking change (such as an update to the new QDK version or modifying any package dependencies), you need to make sure that this still works. - You can check this by pushing your changes to a branch on GitHub and navigating to the Binder link used for the Katas (https://mybinder.org/v2/gh/Microsoft/QuantumKatas/master?filepath=index.ipynb) and change account name (`microsoft`) and branch (`master`) in the url to your Github username and branch name, respectively. After that you can navigate to the kata you want to check using the links from index notebook. + You can check this by pushing your changes to a branch on GitHub and navigating to the Binder link used for the Katas (https://mybinder.org/v2/gh/Microsoft/QuantumKatas/master?filepath=index.ipynb) and change account name (`microsoft`) and branch (`master`) in the url to your GitHub username and branch name, respectively. After that you can navigate to the kata you want to check using the links from index notebook. 3. **Continuous integration** When you open a pull request or add a commit to it, continuous integration pipeline is executed to validate your changes. You can see the details of jobs executed in the "Checks" section on the pull request page; make sure to monitor the results, and if the run fails, try to figure out the reason and fix it. diff --git a/BasicGates/BasicGates.ipynb b/BasicGates/BasicGates.ipynb index 2136cc81..c83d41b8 100644 --- a/BasicGates/BasicGates.ipynb +++ b/BasicGates/BasicGates.ipynb @@ -390,7 +390,7 @@ "\n", "### Q# materials\n", "\n", - "* Using controlled and adjoint versions of gates is covered in the Q# documentation on [operation types](https://docs.microsoft.com/quantum/language/type-model#operation-and-function-types)." + "* Using controlled and adjoint versions of gates is covered in the Q# documentation on [operations](https://docs.microsoft.com/quantum/user-guide/using-qsharp/operations-functions#controlled-and-adjoint-operations)." ] }, { @@ -540,9 +540,9 @@ "file_extension": ".qs", "mimetype": "text/x-qsharp", "name": "qsharp", - "version": "0.10" + "version": "0.12" } }, "nbformat": 4, "nbformat_minor": 2 -} \ No newline at end of file +} diff --git a/DeutschJozsaAlgorithm/DeutschJozsaAlgorithm.ipynb b/DeutschJozsaAlgorithm/DeutschJozsaAlgorithm.ipynb index 3c667c2a..879722ca 100644 --- a/DeutschJozsaAlgorithm/DeutschJozsaAlgorithm.ipynb +++ b/DeutschJozsaAlgorithm/DeutschJozsaAlgorithm.ipynb @@ -15,6 +15,7 @@ "* Deutsch-Jozsa algorithm for recognizing a function as constant or balanced, and\n", "* writing tests in Q#.\n", "\n", + "You can read more about the quantum oracles, Deutsch and Deutsch-Jozsa algorithms in the [ExploringDeutschJozsaAlgorithm tutorial](../tutorials/ExploringDeutschJozsaAlgorithm/DeutschJozsaAlgorithmTutorial.ipynb).\n", "\n", "Each task is wrapped in one operation preceded by the description of the task.\n", "Your goal is to fill in the blanks (marked with `// ...` comments)\n", @@ -128,7 +129,7 @@ "\n", "
\n", "
\n", - " Need a hint? Click here\n", + " Need a hint? Click here\n", " Since $f(x) = 1$ for all values of x, $|y \\oplus f(x)\\rangle = |y \\oplus 1\\rangle = |NOT y\\rangle$.\n", " This means that the operation needs to flip qubit y (i.e. transform $|0\\rangle$ to $|1\\rangle$ and vice versa).\n", "
" @@ -195,7 +196,7 @@ "\n", "
\n", "
\n", - " Need a hint? Click here\n", + " Need a hint? Click here\n", " $f(x)$ can be represented as $x_0 \\oplus x_1 \\oplus ... \\oplus x_{N-1}$.\n", "
" ] @@ -263,7 +264,7 @@ "\n", "
\n", "
\n", - " Need a hint? Click here\n", + " Need a hint? Click here\n", " Since each addition is done modulo 2, you can evaluate the effect of each term independently$.\n", "
" ] @@ -302,9 +303,8 @@ "\n", "> A prefix of length K of a state $|x\\rangle = |x_0, ..., x_{N-1}\\rangle$ is the state of its first K qubits $|x_0, ..., x_{K-1}\\rangle$. For example, a prefix of length 2 of a state $|0110\\rangle$ is 01.\n", "\n", - "
\n", "
\n", - " Need a hint? Click here\n", + " Need a hint? Click here\n", " The first term is the same as in task 1.4. To implement the second term, you can use `Controlled` functor which allows to perform multicontrolled gates (gates with multiple control qubits).\n", "
" ] @@ -344,8 +344,8 @@ "\n", "
\n", "
\n", - " Need a hint? Click here\n", - " Represent f(x) in terms of AND and $\\oplus$ operations.\n", + " Need a hint? Click here\n", + " Represent $f(x)$ in terms of AND and $\\oplus$ operations.\n", "
" ] }, @@ -378,6 +378,7 @@ "\n", "This algorithm solves the following problem. You are given a quantum oracle which implements a classical function $f(x): \\{0, 1\\}^N \\to \\{0, 1\\}$. You are guaranteed that the function $f$ is either constant (has the same value for all inputs) or balanced (has value 0 for half of the inputs and 1 for the other half of the inputs). The goal of the algorithm is to figure out whether the function is constant or balanced in just one oracle call.\n", " \n", + "* You can read more about the Deutsch-Jozsa algorithms and explore its finer points in the [ExploringDeutschJozsaAlgorithm tutorial](../tutorials/ExploringDeutschJozsaAlgorithm/DeutschJozsaAlgorithmTutorial.ipynb).\n", "* You can read more about the Deutsch-Jozsa algorithm in [Wikipedia](https://en.wikipedia.org/wiki/Deutsch%E2%80%93Jozsa_algorithm).\n", "* [Lecture 5: A simple searching algorithm; the Deutsch-Jozsa algorithm](https://cs.uwaterloo.ca/~watrous/CPSC519/LectureNotes/05.pdf)." ] @@ -564,7 +565,7 @@ "> Note that this task relies on your implementations of the previous tasks. If you are getting the \"No variable with that name exists.\" error, you might have to execute previous code cells before retrying this task.\n", "\n", "
\n", - " Need a hint? Click here\n", + " Need a hint? Click here\n", " Not all oracles from part I can be represented as scalar product functions. The most generic oracle you can use in this task is Oracle_ProductFunction from task 1.5; Oracle_Zero, Oracle_Kth_Qubit and Oracle_OddNumberOfOnes are special cases of this oracle.\n", "
" ] @@ -629,7 +630,7 @@ "\n", "
\n", "
\n", - " Need a hint? Click here\n", + " Need a hint? Click here\n", " For each oracle there are multiple bit vectors that generate it; it is sufficient to find any one of them.\n", "
" ] diff --git a/Dockerfile b/Dockerfile index 781b2bd7..6de42b3e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,22 +25,23 @@ RUN pip install -I --no-cache-dir \ USER ${USER} # Pre-exec notebooks to improve first-use start time +# (the katas that are less frequently used on Binder are excluded to improve overall Binder build time) RUN cd ${HOME} && \ ./scripts/prebuild-kata.sh BasicGates && \ ./scripts/prebuild-kata.sh CHSHGame && \ ./scripts/prebuild-kata.sh DeutschJozsaAlgorithm && \ ./scripts/prebuild-kata.sh DistinguishUnitaries && \ - ./scripts/prebuild-kata.sh GHZGame && \ + #./scripts/prebuild-kata.sh GHZGame && \ ./scripts/prebuild-kata.sh GraphColoring && \ ./scripts/prebuild-kata.sh GroversAlgorithm && \ ./scripts/prebuild-kata.sh JointMeasurements && \ - ./scripts/prebuild-kata.sh KeyDistribution_BB84 && \ - ./scripts/prebuild-kata.sh MagicSquareGame && \ + #./scripts/prebuild-kata.sh KeyDistribution_BB84 && \ + #./scripts/prebuild-kata.sh MagicSquareGame && \ ./scripts/prebuild-kata.sh Measurements && \ ./scripts/prebuild-kata.sh PhaseEstimation && \ - ./scripts/prebuild-kata.sh QEC_BitFlipCode && \ + #./scripts/prebuild-kata.sh QEC_BitFlipCode && \ ./scripts/prebuild-kata.sh QFT && \ - ./scripts/prebuild-kata.sh RippleCarryAdder && \ + #./scripts/prebuild-kata.sh RippleCarryAdder && \ ./scripts/prebuild-kata.sh SolveSATWithGrover && \ ./scripts/prebuild-kata.sh SuperdenseCoding && \ ./scripts/prebuild-kata.sh Superposition && \ diff --git a/GraphColoring/GraphColoring.ipynb b/GraphColoring/GraphColoring.ipynb index ed8c2329..1a752f10 100644 --- a/GraphColoring/GraphColoring.ipynb +++ b/GraphColoring/GraphColoring.ipynb @@ -357,7 +357,7 @@ "file_extension": ".qs", "mimetype": "text/x-qsharp", "name": "qsharp", - "version": "0.4" + "version": "0.12" } }, "nbformat": 4, diff --git a/GroversAlgorithm/GroversAlgorithm.ipynb b/GroversAlgorithm/GroversAlgorithm.ipynb index b5c51bcc..64d0a0a6 100644 --- a/GroversAlgorithm/GroversAlgorithm.ipynb +++ b/GroversAlgorithm/GroversAlgorithm.ipynb @@ -466,7 +466,7 @@ "file_extension": ".qs", "mimetype": "text/x-qsharp", "name": "qsharp", - "version": "0.4" + "version": "0.12" } }, "nbformat": 4, diff --git a/QEC_BitFlipCode/QEC_BitFlipCode.ipynb b/QEC_BitFlipCode/QEC_BitFlipCode.ipynb index 5093e238..1abd58fa 100644 --- a/QEC_BitFlipCode/QEC_BitFlipCode.ipynb +++ b/QEC_BitFlipCode/QEC_BitFlipCode.ipynb @@ -294,7 +294,7 @@ "file_extension": ".qs", "mimetype": "text/x-qsharp", "name": "qsharp", - "version": "0.4" + "version": "0.12" } }, "nbformat": 4, diff --git a/RippleCarryAdder/RippleCarryAdder.ipynb b/RippleCarryAdder/RippleCarryAdder.ipynb index c29e818a..40448fee 100644 --- a/RippleCarryAdder/RippleCarryAdder.ipynb +++ b/RippleCarryAdder/RippleCarryAdder.ipynb @@ -746,7 +746,7 @@ "file_extension": ".qs", "mimetype": "text/x-qsharp", "name": "qsharp", - "version": "0.4" + "version": "0.12" } }, "nbformat": 4, diff --git a/SuperdenseCoding/SuperdenseCoding.ipynb b/SuperdenseCoding/SuperdenseCoding.ipynb index bbfaa6f5..06956349 100644 --- a/SuperdenseCoding/SuperdenseCoding.ipynb +++ b/SuperdenseCoding/SuperdenseCoding.ipynb @@ -203,7 +203,7 @@ "file_extension": ".qs", "mimetype": "text/x-qsharp", "name": "qsharp", - "version": "0.4" + "version": "0.12" } }, "nbformat": 4, diff --git a/Teleportation/Teleportation.ipynb b/Teleportation/Teleportation.ipynb index c2177019..32c2e514 100644 --- a/Teleportation/Teleportation.ipynb +++ b/Teleportation/Teleportation.ipynb @@ -474,7 +474,7 @@ "file_extension": ".qs", "mimetype": "text/x-qsharp", "name": "qsharp", - "version": "0.10" + "version": "0.12" } }, "nbformat": 4, diff --git a/tutorials/ExploringGroversAlgorithm/ExploringGroversAlgorithmTutorial.ipynb b/tutorials/ExploringGroversAlgorithm/ExploringGroversAlgorithmTutorial.ipynb index e381ce67..847e6fa0 100644 --- a/tutorials/ExploringGroversAlgorithm/ExploringGroversAlgorithmTutorial.ipynb +++ b/tutorials/ExploringGroversAlgorithm/ExploringGroversAlgorithmTutorial.ipynb @@ -584,7 +584,7 @@ "file_extension": ".qs", "mimetype": "text/x-qsharp", "name": "qsharp", - "version": "0.4" + "version": "0.12" } }, "nbformat": 4, diff --git a/tutorials/MultiQubitGates/MultiQubitGates.ipynb b/tutorials/MultiQubitGates/MultiQubitGates.ipynb index 31487422..e38e0106 100644 --- a/tutorials/MultiQubitGates/MultiQubitGates.ipynb +++ b/tutorials/MultiQubitGates/MultiQubitGates.ipynb @@ -634,7 +634,7 @@ " 0 & 0 & \\alpha & \\beta \\\\\n", " 0 & 0 & \\gamma & \\delta\n", " \\end{bmatrix}$\n", - " Controlled functor\n", + " Controlled functor\n", " \n", "\n", "\n", diff --git a/tutorials/MultiQubitSystems/MultiQubitSystems.ipynb b/tutorials/MultiQubitSystems/MultiQubitSystems.ipynb index c2df94aa..ae2bf249 100644 --- a/tutorials/MultiQubitSystems/MultiQubitSystems.ipynb +++ b/tutorials/MultiQubitSystems/MultiQubitSystems.ipynb @@ -571,7 +571,7 @@ "file_extension": ".qs", "mimetype": "text/x-qsharp", "name": "qsharp", - "version": "0.10" + "version": "0.12" } }, "nbformat": 4, diff --git a/tutorials/Qubit/Qubit.ipynb b/tutorials/Qubit/Qubit.ipynb index 23812fa2..390df312 100644 --- a/tutorials/Qubit/Qubit.ipynb +++ b/tutorials/Qubit/Qubit.ipynb @@ -295,7 +295,7 @@ "file_extension": ".qs", "mimetype": "text/x-qsharp", "name": "qsharp", - "version": "0.10" + "version": "0.12" } }, "nbformat": 4, diff --git a/tutorials/SingleQubitGates/SingleQubitGates.ipynb b/tutorials/SingleQubitGates/SingleQubitGates.ipynb index 6bcb1af7..44b98470 100644 --- a/tutorials/SingleQubitGates/SingleQubitGates.ipynb +++ b/tutorials/SingleQubitGates/SingleQubitGates.ipynb @@ -351,11 +351,25 @@ "Z|-i\\rangle = |i\\rangle$ \n", " Z\n", " \n", - "\n", - "\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "> The $X$ gate is sometimes referred to as the **bit flip** gate, or the **NOT** gate, because it acts like the classical NOT gate on the computational basis.\n", ">\n", - "> The $Z$ gate is sometimes referred to as the **phase flip** gate." + "> The $Z$ gate is sometimes referred to as the **phase flip** gate.\n", + "\n", + "Here are several properties of the Pauli gates that are easy to verify and convenient to remember:\n", + "\n", + "* Different Pauli gates *anti-commute*:\n", + " $$XZ = -ZX, XY = -Y, YZ = -ZY$$\n", + "* A product of any two Pauli gates equals the third gate, with an extra $i$ (or $-i$) phase:\n", + " $$XY = iZ, YZ = iX, ZX = -Y$$\n", + "* A product of all three Pauli gates equals identity (with an extra $i$ phase):\n", + " $$XYZ = iI$$" ] }, { @@ -921,7 +935,7 @@ "file_extension": ".qs", "mimetype": "text/x-qsharp", "name": "qsharp", - "version": "0.10" + "version": "0.12" } }, "nbformat": 4,