InfoQ Homepage News Microsoft Quantum Katas Help Developers Discover Quantum Computing with Q#

# Microsoft Quantum Katas Help Developers Discover Quantum Computing with Q#

Based on the idea of code katas, Microsoft has open-sourced a new project called Quantum Katas, that aims to help developers move their first steps in quantum computing using the Q# language. Quantum Katas are a set of programming exercises of growing complexity that provide immediate feedback to learners.

Currently, four katas are available, each covering a specific quantum topic:

• How to use the basic quantum computing gates, using both single-qubit and multi-qubit gates.
• Preparing states in superposition. Superposition is one of the most peculiar properties of quantum systems, along with entanglement, and enables the existence of multiple logical states at the same time in a given qubit.
• Using measurements to extract classical information from a quantum experiment. The measurement step may destroy the coherence of a quantum system by bringing the qubit state out of superposition.
• Writing quantum oracles that implement classical functions and the Deutsch–Jozsa algorithm, one of the first examples of a quantum algorithm that is exponentially faster than any possible deterministic classical algorithm.

A kata is organized as a set of coding tasks of growing complexity. Each task, along the lines of test driven programming, is associated with a unit test that initially fails. The developer fills in the code that makes the test pass with the help of available reference material, provided in the kata along with a reference solution.

The problems included in the katas come from the first Q# coding contest that Microsoft ran last July.

The following is an example of an almost trivial task, consisting in flipping the state of a qubit, and a more complex one, consisting in changing the qubit state based on its current state:

    //////////////////////////////////////////////////////////////////
// Part I. Single-Qubit Gates
//////////////////////////////////////////////////////////////////

// Task 1.1. State flip: |0⟩ to |1⟩ and vice versa
// Input: A qubit in state |ψ⟩ = α |0⟩ + β |1⟩.
// Goal:  Change the state of the qubit to α |1⟩ + β |0⟩.
// Example:
//        If the qubit is in state |0⟩, change its state to |1⟩.
//        If the qubit is in state |1⟩, change its state to |0⟩.
// Note that this operation is self-adjoint: applying it for a second time
// returns the qubit to the original state.
operation StateFlip (q : Qubit) : ()
{
body
{
// The Pauli X gate will change the |0⟩ state to the |1⟩ state and vice versa.
// Type X(q);
// Then rebuild the project and rerun the tests - T11_StateFlip_Test should now pass!

// ...
}
}

// Inputs:
//     1) A qubit in state β|0⟩ + γ|1⟩.
//     2) Angle alpha, in radians, represented as Double
// Goal:  Change the state of the qubit as follows:
//        If the qubit is in state |0⟩, don't change its state.
//        If the qubit is in state |1⟩, change its state to exp(i*alpha)|1⟩.
//        If the qubit is in superposition, change its state according to the effect on basis vectors.
operation PhaseChange (q : Qubit, alpha : Double) : ()
{
body
{
// ...
}
}


Taking Microsoft Quantum Katas requires installing the Quantum development Kit, which is available for Wnidows 10, macOS, and Linux. Each kata is located in its own directory with an associated Visual Studio solution. On macOS and Linux, you can run the katas using Visual Studio Code or the command line, provided you have installed the .NET Core SDK 2.0 or later.

Style

## Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

• ##### As complex as direct binary programming with paper tapes

by Néstor Sánchez /

• ##### As complex as direct binary programming with paper tapes

Your message is awaiting moderation. Thank you for participating in the discussion.

This is a valuable effort in the right direction, but still only for system programmers. Someday I hope to see a higher level of abstraction framework, without any greek letter or scientist names, just clear operations (a semantic jump like was with SQL) to take advantage of the possibilities and none of the complex internal working physics of quantum computing.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.