QuantumKatas
Tutorials and programming exercises for learning Q# and quantum computing
Install / Use
/learn @microsoft/QuantumKatasREADME
DEPRECATION NOTICE
We are modernizing the quantum katas experience. Please visit https://quantum.microsoft.com/experience/quantum-katas to try the new online Azure Quantum katas experience, with integrated assistance from Copilot in Azure Quantum.
For the Modern QDK repository, please visit Microsoft/qsharp.
For more information about the Modern QDK and Azure Quantum, visit https://aka.ms/AQ/Documentation.
Introduction
The Quantum Katas are a collection of self-paced tutorials and programming exercises to help you learn quantum computing and Q# programming.
Each kata is a separate set of exercises that includes:
- A sequence of tasks progressing from easy to hard. Each task requires you to fill in some code. The first task might require just one line, and the last one might require rather complicated code.
- A testing framework that sets up, runs, and validates your solutions. Each task is covered by a unit test which initially fails. Once you write the code to make the test pass, you can move on to the next task.
- Links to quantum computing and Q# reference material you might need to solve the tasks.
- Hints, reference solutions and detailed explanations to help you if you're stuck.
The Quantum Katas also include tutorials that introduce the learner to the basic concepts and algorithms used in quantum computing, starting with the necessary math (complex numbers and linear algebra). They follow the same pattern of supplementing the theory with Q# demos and hands-on programming exercises.
Table of contents
Learning path <a name="learning-path" />
Here is the learning path we suggest you to follow if you are starting to learn quantum computing and quantum programming. Once you're comfortable with the basics, you're welcome to jump ahead to the topics that pique your interest!
Quantum Computing Concepts: Qubits and Gates
- Complex arithmetic (tutorial). Learn about complex numbers and the mathematics required to work with quantum computing.
- Linear algebra (tutorial). Learn about vectors and matrices used to represent quantum states and quantum operations.
- The qubit (tutorial). Learn what a qubit is.
- Single-qubit gates (tutorial). Learn what a quantum gate is and about the most common single-qubit gates.
- Basic quantum computing gates. Learn to apply the most common gates used in quantum computing.
- Multi-qubit systems (tutorial). Learn to represent multi-qubit systems.
- Multi-qubit gates (tutorial). Learn about the most common multi-qubit gates.
- Superposition. Learn to prepare superposition states.
Quantum Computing Concepts: Measurements
- Single-qubit measurements (tutorial). Learn what quantum measurement is and how to use it for single-qubit systems.
- Multi-qubit measurements (tutorial). Learn to use measurements for multi-qubit systems.
- Measurements. Learn to distinguish quantum states using measurements.
- Distinguish unitaries. Learn to distinguish unitaries by designing and performing experiments with them.
- Joint measurements. Learn about using joint (parity) measurements to distinguish quantum states and to perform state transformations.
Q# and Microsoft Quantum Development Kit Tools
- Visualization tools (tutorial). Learn to use the various tools for visualizing elements of Q# programs.
Simple Algorithms
- Random number generation (tutorial). Learn to generate random numbers using the principles of quantum computing.
- Teleportation. Implement standard teleportation protocol and its variations.
- Superdense coding. Implement the superdense coding protocol.
Quantum Oracles and Simple Oracle Algorithms
- Quantum oracles (tutorial). Learn to implement classical functions as equivalent quantum oracles.
- Marking oracles. Practice implementing marking oracles for a variety of classical functions.
- Exploring Deutsch and Deutsch–Jozsa algorithms (tutorial). Learn to implement classical functions and equivalent quantum oracles, and compare the quantum solution to the Deutsch–Jozsa problem to a classical one.
- Deutsch–Jozsa algorithm. Learn about quantum oracles which implement classical functions, and implement Bernstein–Vazirani and Deutsch–Jozsa algorithms.
- Simon's algorithm. Learn about Simon's algorithm.
Grover's Search Algorithm
- Implementing Grover's algorithm. Learn about Grover's search algorithm and how to write quantum oracles to use with it.
- Exploring Grover's search algorithm (tutorial). Learn more about Grover's search algorithm, picking up where the Grover's algorithm kata left off.
- Solving SAT problems using Grover's algorithm. Explore Grover's search algorithm, using SAT problems as an example. Learn to implement quantum oracles based on the problem description instead of a hard-coded answer. Use Grover's algorithm to solve problems with an unknown number of solutions.
- Solving graph coloring problems using Grover's algorithm. Continue the exploration of Grover's search algorithm, using graph coloring problems as an example.
- Solving bounded knapsack problem using Grover's algorithm. Learn how solve the variants of knapsack problem with Grover's search.
Tools and Libraries/Building up to Shor's Algorithm
- Quantum Fourier transform. Learn to implement quantum Fourier transform and to use it to perform simple state transformations.
- Phase estimation. Learn about phase estimation algorithms.
Entanglement Games
Reversible Computing
- Truth tables. Learn to represent and manipulate Boolean functions as truth tables and to implement them as quantum operations.
- Ripple-carry adder. Build a ripple-carry adder on a quantum computer.
Miscellaneous
- BB84 protocol. Implement the BB84 key distribution algorithm.
- Bit-flip error correcting code. Learn about a 3-qubit error correcting code for protecting against bit-flip errors.
- Unitary patterns. Learn to implement unitaries with matrices that follow certain patterns of zero and non-zero elements.
- Quantum classification (tutorial). Learn about circuit-centric classifiers and the quantum machine learning library included in the QDK.
For a Q# programming language quick reference sheet, see Q# Language Quick Reference.
Run the katas and tutorials online <a name="run-online" />
The Quantum Katas are now available as Jupyter Notebooks online! See index.ipynb for the list of all katas and tutorials, and instructions for running them online.
Note that mybinder.org is running with reduced capacity, so getting a virtual machine and launching the notebooks on it might take several attempts. While running the Katas online is the easiest option to get started, if you want to save your progress and enjoy better performance, we recommend you to choose the local setup option.
Run the katas locally <a name="kata-locally" />
Quantum Development Kit Installation <a name="install" />
To use the Quantum Katas locally, you'll need the Quantum Development Kit, available for Windows 10, macOS, and Linux. If you don't already have the Quantum Development Kit installed, see the install guide for the Quantum Development Kit.
If you want to run the katas and tutorials locally as Jupyter Notebooks:
- Follow the steps in the QDK install guide for Python and the QDK install guide for Jupyter Notebooks.
- Several tutorials require installing additional Python packages:
- "Complex arithmetic" and "Linear algebra" require the
pytestpackage. - "Exploring Grover's search algorithm" requires the [
matplotlibpackage](https://m
- "Complex arithmetic" and "Linear algebra" require the
