Let me continue the topic of teaching and learning quantum computing that I touched upon yesterday and share with you the project done by my summer intern Artem Astapchuk –

The post New Tutorials: Learn the Basic Concepts of Quantum Computing appeared first on Q# Blog.

]]>Let me continue the topic of teaching and learning quantum computing that I touched upon yesterday and share with you the project done by my summer intern Artem Astapchuk – a set of tutorials that introduce the most basic concepts used in quantum computing.

The Quantum Katas start with the BasicGates kata – a set of exercises that ask the learner to identify the quantum gate that will perform the described transformation of a qubit state. It seems like a very easy thing to do – how hard can it be to look up a list of quantum gates and match one of them to the task?

Turns out, it is pretty hard for somebody who sees the quantum computing notation for the first time. Even the easiest task that asks to apply the Pauli X gate relies on a lot of implied knowledge. What is a qubit and its state? What are these weird symbols around 0 and 1? What kind of tools do you use to change the state of the qubit? And how do you express all this in Q#?

Historically the Katas sent the learner to find an external source for learning the basic concepts and notations used in quantum computing. However, eventually it started to make more sense to create a set of tutorials that would teach the learner everything they need to start solving the first katas in one place and using one style.

Well, here they are! Two tutorials that cover the math necessary for working with quantum computing – complex arithmetic and linear algebra – are written in Python, and the four that introduce the quantum computing concepts – qubits and superposition, multi-qubit systems and entanglement, and single- and multi-qubit gates – are implemented in Q#.

We tried to steer away from too much theory and to give just the definitions and the tools necessary for getting started (yes, qubit states are described using Hilbert spaces; no, you don’t need to know this to start learning). Instead, we focused on making the learning process as hands-on as possible, using demos and programming exercises to help learner internalize the new concepts and ideas by applying them to solving simple tasks.

For example, the definition of the imaginary unit *i* is immediately followed by a programming task that asks one to calculate the *n*-th power of *i* *iⁿ*; the introduction of the qubit states is followed by a demo that shows how to examine and interpret the qubit state in Q# using the DumpMachine function, and so on.

If you’re looking to get started with quantum computing, give these tutorials a try and let us know what you think!

Meanwhile, we’ll keep working on bringing you more tutorials. Next up: measurements!

The post New Tutorials: Learn the Basic Concepts of Quantum Computing appeared first on Q# Blog.

]]>This winter our team had an exciting opportunity to teach an introductory course on quantum computing at the University of Washington, led by Krysta Svore.

The post Teaching Quantum Computing with Q# appeared first on Q# Blog.

]]>This winter our team had an exciting opportunity to teach an introductory course on quantum computing at the University of Washington, led by Krysta Svore. It was a special experience for all of us, but especially for me, since I’ve never been involved in the university education process in any role other than a student.

*If you prefer watching videos to reading, here are the videos from Microsoft Faculty Summit 2019, where Martin Roetteler and I talk about our experience teaching this course: part 1 and part 2.*

First of all we had to figure out what we are going to cover in the course and how to teach it. Quantum computing is a huge field, and can be taught from a variety of different angles, from quantum physics and the physical realization of quantum computers to pure quantum information theory. What to choose?

We decided to approach the subject from a computer scientist’s point of view, focusing on programming and solving practical problems. Indeed, a typical course in classical computing starts by introducing a programming language and teaching the students to use it to solve simple tasks; then it covers basic algorithms and data structures, with homework assignments centered around implementing the data structures and using the algorithms to solve more complicated tasks; finally, the students have a choice of courses on more advanced topics (again with practical applications), capstone projects etc. You don’t often see a classical software engineer who would be trained in transistor physics and computational complexity theory but who only ever implemented algorithms on paper!

We ended up creating a course leaning heavily towards the practical implementation of quantum algorithms; it included both written assignments and programming assignments, with the latter accounting for a larger share of the final grade than the former, and a final programming project instead of a more customary written exam or a presentation-style project.

Our main tool for teaching the students quantum programming were the Quantum Katas. I’ve mentioned them before once or twice, so I won’t go into great detail on them again – I’ll just note that they are as good for classroom learning as they are for self-paced. In addition, they did a really good job of preparing the students for their homework.

Programming assignments were structured exactly like the katas (that was before we introduced the Jupyter Notebooks, so all programming materials were Q# projects): the students would get a file with task descriptions and the skeleton operations for them, and they’d have to fill in the code that solves the tasks. Here, for example, is the first task from week 4 of the course, in which we covered quantum oracles:

The neatest thing about the programming assignments was that they were graded automatically. (I’ve never been in a TA’s shoes myself, but I can certainly sympathize with the need to grade over 30 assignments!) Similarly to the katas, each task of the assignment was covered by a test, and if the test passed, the solution was judged correct.

In week 6 of the course we tried a different flavor of a programming assignment: the students had to do resource estimation for Shor’s algorithm implemented in our samples. These tools would come handy for them later in the course.

The last programming assignment was even more unusual for quantum computing courses than the previous ones: the students were to take part in the Q# Coding Contest, which was conveniently held during the last month of the course. Programming courses on algorithms or machine learning sometimes use a similar approach, offering problems from Kaggle, Codeforces or other online judges as assignments or even hosting small programming competitions for the students.

However exciting hosting the contest was for us, the students didn’t take it well. A lot of topics in the contest were covered in the course, but the contest tasks were much harder than the homework assignments. Add the extra pressure from the timed nature of the competition and the requirement to participate in it alone, and the results were disappointing: only one student solved all problems.

The final projects were small capstones for the course: the students would form teams of 2-3 people and work on a quantum computing problem of their choice, going through all the steps from choosing and defining the problem to solving it and implementing the solution in Q# to describing the solution in a mini-paper and presenting it to the class.

This was the favorite part of the course for a lot of students. On the one hand, it allowed them to focus on any topic they were excited about and to deep-dive into it. On the other hand, it was extremely practical: the students had a chance to actually experiment with their algorithms of choice, figure out how much resources are required to run them and how to construct a small instance of a problem that can be solved on a simulator, optimize their solutions and compare different implementations — in other words, do a lot of things that comprise a quantum software engineer’s day work!

The last two lectures of the course were dedicated to the final projects presentations. This was when I got to finally meet the students in person (before that I focused on behind-the-scenes parts of the course, so the students knew me only as a disembodied online presence). The range of projects done by the students was quite impressive — from entanglement games and key distribution protocols to quantum chemistry and a Bitcoin mining algorithm!

The course has completed over half a year ago, but it had more lasting outcomes than just a pass/fail grade for the students who took it.

First, several teams chose to frame their final projects as new katas and to contribute them back to the Quantum Katas project for the next generation of learners to use.

Second, several students went on to do internships at companies who work on quantum computing (well, most of those were on our team, but that still counts!) and quite possibly will make a career in it.

Finally, we learned a lot about the best ways to teach people quantum computing. We really hope to teach a new, updated and improved version of this course soon! Meanwhile, we are happy to share our materials and learnings with other instructors looking to teach quantum computing from a practical point of view (if you’re interested, contact me at mamykhai@microsoft.com).

The post Teaching Quantum Computing with Q# appeared first on Q# Blog.

]]>The post One Year of Quantum Katas appeared first on Q# Blog.

]]>The first release of the Quantum Katas had only 4 katas, covering basic gates used in quantum computing, the concept of superposition, the use of measurements, quantum oracles and Deutsch–Jozsa algorithm. Even with this seemingly scarce material they were very useful for people learning quantum computing, but it was obvious that we needed more topics.

The first big batch of the new katas came in from Microsoft’s OneWeek Hackathon – a yearly global event that brings together Microsoft employees and interns to tackle unusual and exciting projects. A group of hackers from different countries got together to learn something about quantum computing and to write new katas about the topics they’ve just learned.

This Hackathon brought in such gems as the katas on teleportation, superdense coding,

Simon’s algorithm and Grover’s algorithm – all of them essential stepping stones on the way to mastering quantum computing, and all of them already used in teaching these topics.

Outside of the Hackathon things looked quiet for a while: in the half a year since the katas were released we added only two new katas – the ones on joint measurements and on the bit-flip error correction code. But behind the scenes work was in full swing: we were preparing for the next big events – the course on quantum computing we were going to teach in University of Washington and the second Q# coding contest.

The impact of the course was two-fold. On one hand, we heavily relied on the katas for teaching the students Q#, but at that point the katas covered the introductory topics well enough that we only needed to write one new kata, the one on phase estimation. On the other hand, a lot of students elected to write a kata or several as their final project in the course and to contribute them back to the project. The set of three katas on quantum entanglement games was one of these final projects, as well as the prototype of the kata on solving graph coloring problems using Grover’s algorithm (and there are more lined up!).

For the second Q# coding contest, we took a brief detour from the usual learning path and wrote a very uncommon kata called UnitaryPatterns. It offers tasks of the following form: given a pattern of zero and non-zero elements in a square matrix of size 2^{N} × 2^{N}, write a Q# operation that implements a unitary transformation on N qubits described by a matrix that matches this pattern.

These are not the kind of tasks you’ll often see in a book, but they make for a really great brainteaser – and teach you a lot about what it means for a matrix to be unitary and about decomposing unitary transformations into Q# operations.

Another kata written for the contest aims to answer one of the most frequent questions about Grover’s search algorithm: how to implement an oracle for the search problem if you don’t know the answer yet, and what’s the point of implementing an oracle if you already know the answer? SAT problems are a perfect example of problems that can be expressed as oracles and tackled using Grover’s search, as shown by this kata.

The next big step for the evolution of the Quantum Katas were Jupyter Notebooks for Q#. I’ve already praised them for making an excellent front-end for the existing katas, so I won’t repeat the odes here – I’ll just point out that (due to relentless effort of our community) 13 of the katas are already available online as Jupyter Notebooks, and the rest of them are coming soon.

But the benefits of the Notebooks don’t end at the beautiful presentation for existing problems…

Jupyter Notebooks open the door to a whole world of new possibilities. The most obvious of them is writing proper tutorials that explain a topic using a mix of theory, visualization, Q# code samples/small demos and programming exercises. The first of such tutorials is already up – it offers you a rather extensive exploration of the Deutsch–Jozsa algorithm, including the classical solution to the problem and an introduction to phase oracles and implementing them in Q#.

We hope you find the growing Quantum Katas project useful. Stay tuned as we share with you new tutorials and programming exercises!

The post One Year of Quantum Katas appeared first on Q# Blog.

]]>The post Solve the Quantum Katas Online with Jupyter Notebooks appeared first on Q# Blog.

]]>Today, we present the first batch of the Quantum Katas in Notebook format! Those of you who have already tried out the Quantum Katas or attended one of our workshops on quantum computing will recognize the benefits of the new format immediately:

- You don’t need to install anything locally to solve the katas. No more frenzied installations the night before the workshop (or even during the workshop!) – you can run the katas online in any browser using Binder.
- The presentation is a lot smoother and more polished. Even with the Unicode support in Q# comments, there is a dramatic difference in task rendering, since the Notebooks provide full HTML and LaTeX support, and allow images to be incorporated in the task descriptions.
Notebooks also allow hints to be hidden until they are needed, as opposed to just being visible in the code upfront. (For the best experience with the hints, we recommend using Firefox, Chrome or Microsoft Edge Dev build.)

- The solution template given in the Notebook does not have to compile, as long as you don’t attempt to solve the task. The solution template given in a Q# project must compile to tell you that your solution is incorrect, so the tasks frequently return a placeholder value just to make the code valid – and for some of the trickier tasks that value is not trivial and sometimes confusing.

We will eventually convert all the katas to Notebook format, so that you can solve them in your preferred environment. Meanwhile, try the katas that are already converted and let us know what you think!

The post Solve the Quantum Katas Online with Jupyter Notebooks appeared first on Q# Blog.

]]>The post Learn Quantum Computing with the Quantum Katas appeared first on Q# Blog.

]]>There were several problems with the book – or, more likely, with this style of learning. First, the exercises in the book didn’t have answers, or any hints for that matter. Once I solved a problem, I had no idea whether my approach was correct, and if I was stuck, I was on my own. I was lucky to have access to a whole team of quantum computing experts, whom I could pester with my questions; most people who want to learn quantum computing on their own don’t have this luxury. Second, the book approaches a lot of things from a theoretical point of view, and I don’t believe you can truly master an algorithm – quantum or classical – until you’ve actually implemented it. There is a world of difference between reading explanations and formulas or even following the calculations with pen and paper and writing the code, making mistakes and finding them, seeing how it behaves on different inputs and so on.

Of course, one can (and should) turn to other sources for the exercises. I’ve greatly enjoyed the Quantum Information Science courses by MIT on EdX, since they had interesting problem sets with solution verification. But still I felt that there should be more to teaching quantum computing than that…

Last winter, after we released the Quantum Development Kit 0.1, I started to think about how to help people learn Q# – and for that they would need to learn quantum computing. Examples and library code showing algorithms’ implementations or step-by-step follow-along tutorials like Writing a quantum program were clearly not sufficient, since they lacked the learn-by-doing aspect, giving the learner neither motivation nor framework to experiment on their own.

And then I recalled FSharpKoans through which I went the previous year when learning F#. Those were really good – fun and engaging (who doesn’t love fixing things?) while useful for learning the syntax and concepts of the language. Could we do something like that for Q#?

Fast forward several months: we proudly presented the Quantum Katas – an open-source project aimed at teaching quantum computing and Q# programming.

Working with the Quantum Katas in Visual Studio

The Quantum Katas follow several key principles.

Each kata offers you programming exercises on one topic or a set of closely related topics. They don’t offer you the theory on these topics – for that they send you to external sources like lecture notes or Wikipedia (you’re also most welcome to find your own favorite resource). Once you’ve gone through the theory, you dive into the exercises to internalize your newly gained knowledge. Each task requires you to write a fragment of code to implement something you’ve learned.

Each kata includes a testing framework which validates your solutions to the tasks as soon as you write them. The level of detail provided varies from topic to topic: if the problem asks you to create a certain superposition state, you’ll know only whether the state you created was correct or not (and if it was not, you can use debugging tools like DumpMachine to see what state you created); if the problem asks you to perform quantum state discrimination, you’ll know what percentage of the given states you’ve misclassified, and so on.

The tasks in each kata start simple and gradually increase in complexity, building up on the previous ones. The Superposition kata, for example, starts with really simple tasks – create a |+⟩ or a |-⟩ state – and builds up to creating a W state, which requires using recursion and some clever rotations or even more clever post-selection tricks.

If you want to master a classical algorithm, you don’t implement the algorithm alone – you also write some unit tests to run it and verify that your implementation works (at least you should). The same goes for quantum algorithms: if a kata covers an oracle algorithm like Grover’s search or a protocol like teleportation, it will take you through all the steps:

- writing an oracle in the right format for the algorithm or preparing the shared resources for the protocol,
- implementing the algorithm itself,
- putting all the pieces together to run the algorithm or the protocol and to check that you get the expected result.

The Quantum Katas project is still in its early stages – there are only 10 katas, covering the introductory topics – but it has already proven itself quite useful. We’ve used the katas in several guided workshops, where the hands-on work with them was preceded by a lecture on the necessary quantum computing concepts, with great success. And personally I felt that I really understood the Grover’s algorithm only after I test-solved the respective kata contributed in October

Speaking of contributions… If you have an idea for a nice new task or even a whole new kata, let us know and we’ll be happy to help you implement it!

The post Learn Quantum Computing with the Quantum Katas appeared first on Q# Blog.

]]>