WHT

Q Tutorial | Microsoft Quantum Development Kit: Introduction And Step-by-step Demo

Microsoft Mechanics

Subscribe Here

Likes

3,372

Views

177,277

Microsoft Quantum Development Kit: Introduction And Step-by-step Demo

Transcript:

Coming up, I’ll walk you through the new Microsoft quantum development kit, now in preview. This is an important milestone that we’ve been working on to empower you in the quantum computing revolution. It forms a part of our differentiated approach to delivering a scalable quantum system. The Quantum Development Kit makes it easy for you to start experimenting now it includes a native quantum-focused programming language called Q# (‘Q sharp’), local and Azure-hosted simulators for you to test your Q# solution, and sample cue sharp code and libraries to help you get started. In the next few minutes I’ll walk through a few code examples and I’ll explain where quantum principles like superposition and entanglement apply. If these concepts are new to you then check out our previous episode to learn more and you can download the code from our website (www.microsoft.com/quantumdevkit) to follow along. Let’s get started. Here I’m in Visual Studio I’d like to start with our version of “Hello World” and quantum computing called teleportation, which is core to quantum algorithms and a great primer to begin your quantum computing journey. Teleportation enables communication between quantum bits on a single piece of quantum hardware or even between remote quantum computers it serves as a basis of a future quantum Internet and shares many operations with quantum algorithms you will create and develop. In this program I’ll highlight the steps to initialize quantum resources, apply operations and run your quantum algorithm. Let’s look at the code. I’ve opened two project files for this demo one in our native quantum language Q# and the other in a standard programming language C# this is because a quantum computer is like a coprocessor, it’s much like how you program a GPU or FPGA and then call the code for the accelerator from say your CPU. Q# is designed with a similar hybrid compute model in mind now let’s look at the Q# program the syntax should look somewhat familiar as we’ve designed it with ideas drawn from languages like C# and F#. For example here you have code colorization you can define and call operations use let and if commands and more the teleport classical message operation takes as input a classical message represented by a boolean value. The first thing to do is allocate a register to store quantum information here I’ve allocated two qubits initially assigned to the state 0 with the using this command. I then assign each qubit a name message and there I’m going to encode the message into the message qubit by applying an X operation which is analogous to a NOT in classical logic. Here if the message is 1 we apply the X operation to the qubit message flipping its state to teleport the message let’s look at this operation teleport. Teleport takes two qubits as input message and there the first step is to allocate one more qubit and we call it here it’s also initialized to state 0. Now we use the H operation or Hadamard gate to place our qubit here into a superposition state H takes the state 0 to 0 plus 1 and the state 1 to 0 minus 1 recall that a qubit is a quantum bit of information and it can be in a so-called superposition of values not just 0 or 1 like a classical bit but rather a combination of 0 and 1. This leads to a type of massive parallelism we can exploit in quantum algorithms and is a key quantum operation that you will use at the start of most every quantum algorithm you design now after placing here into superposition we apply a two qubit controlled-not or CNOT gate to the qubits here and there CNOT flips the value of the their qubit if the here qubit is 1 otherwise it does nothing to either 2 bit it’s like an XOR gate in classical logic now together these two operations H and CNOT have enabled us to create entanglement between qubits here and there. Once entangled, the state of these two bits are intrinsically correlated. If I do something to one of them it instantaneously changes the state of the other one even if I’ve spread them across the universe from each other. This entangled pair is a key resource for sending the message. I take the message qubit and load it into the entangled pair using another CNOT on qubits message and here followed by H on qubit message now I need to measure out the entanglement to conclude the teleportation of the message I measure both the message and here qubits using the M operation at the end of a quantum algorithm you will often perform a measurement to project the quantum information to a classical state which you can then output and read here we use the measurement output to conditionally apply quantum operations Z then X to the their qubit now returning to teleport classical message. We can measure the their qubit to see if it has the message let’s check to see if the message was actually teleported into the their qubit and go back to the main calling program in the C# file now the Quantum Development Kit comes with a built in universal quantum simulator with it you can run small instances of your quantum programs on your local hardware to around 30 simulated qubits the qubit restriction is purely driven by your development machine I’m using my everyday laptop for this simulation in general you’ll need 16 GB of RAM to simulate 30 qubits simulating one more qubit requires double the memory simulating one less halfs the memory simulating 40 qubits requires roughly a thousand times more memory than 30 cubits coming in around 16 terabytes so we also offer a simulator hosted and Azure that enables going beyond 40 qubits to test our program let’s initialize and target the local simulator and call teleport classical message eight times each time with a random message of 0 or 1, or true or false. I’m going to print the results of the screen using the functionality of C# now let’s hit run we can see that when the boolean value is true the their qubit also received true so the message has been correctly sent we’ve successfully teleported information and you’ve completed your first quantum algorithm you can also debug your quantum program by setting a breakpoint and stepping through the code which we’ll cover in an upcoming Microsoft Mechanics episode you can also use the built-in trace simulator provided with the preview release to estimate how many qubits and operations you are using in different parts of your quantum program as you can see here in the Excel file. It outputs how many quantum gates are used within the different operations with such information you can optimize your algorithm to reduce the number of qubits and operations required. And we’ll cover this in more detail in future episodes as well. Now let’s take a quick look at a more complex program. This example serves as a foundation for using quantum computing to solve problems in material science or chemistry for example to learn about new catalysts for improving the efficiency of a chemical reaction let’s look at finding the ground state energy of a simple molecule, hydrogen. Now here again we call our quantum program from a classical one this time written in F# in this example we’re going to load classical data about estimations of the bond links and then for each bond length, we use the quantum computer to estimate the ground state energy given that configuration this example also uses many of the built-in library functions in Q# by calling Microsoft.quantum.canon to enable easy programming of a very fundamental quantum algorithm and you can see the many libraries available arithmetic phase estimation and more now in the F# code I can exploit real time plotting to see the output as it’s calculated when I hit run you can see it plotting the ground state energy calculated on the quantum computer 454 different on links the output from the quantum computer as you can see closely matches the results from theory developed over the last several decades. Now molecular hydrogen is a very small molecule with just two hydrogen atoms we can easily simulate it locally to test larger molecules. We can use the Azure base simulator when the algorithm requires more than 40 qubits and ultimately the quantum computer will allow us to go far beyond 40 qubits. We’ll be able to study complex molecules that today require longer than the lifetime of the universe to study on our best supercomputers and it will take just a matter of hours or days with a quantum computer. Our Quantum Development Kit enables you to write programs for these large calculations today so that was a quick introduction to the new Microsoft Quantum Development Kit in preview now you can get started by accessing the preview at the link shown and get access to Q# our simulators code samples and tutorials quantum computers will be revolutionary and enable us to start solving some of the world’s most challenging problems in areas such as machine learning, global warming, and clean energy. To find out more about quantum computing and Microsoft’s approach join our quantum community and thanks for watching. I look forward to seeing how you will harness quantum computing to kickstart the quantum computing revolution.

0.3.0 | Wor Build 0.3.0 Installation Guide

Transcript: [MUSIC] Okay, so in this video? I want to take a look at the new windows on Raspberry Pi build 0.3.0 and this is the latest version. It's just been released today and this version you have to build by yourself. You have to get your own whim, and then you...

read more