Quantum Computing: Jupyter Notebooks, where to learn, and more

Some developers don´t feel confortable using VSCode, but… you can run Q# on Jupyter Notebook.

What is Jupyter Notebook?

The Jupyter Notebook is an open-source web application that allow in-place code execution alongside instructions, notes,  it lets you create and share documents that contain live code, equations, visualizations and narrative text.

Do you want to Learn Quantum ?

Learn with Quantum Katas

Microsoft created a series of self-paced tutorials to learn Quantum with Python and also Q# programming. This tutorials help you understand concepts like superposition, measurements and more.

Try Katas:

  • Online: Click here . You will launch a new browser tab with Binder, wait until you have everything ready to start with katas, usually you have to wait a couple of minutes until you get Jupyter Notebook online. Once it loads, you will see the list of tutorials and instructions and you are ready to test and learn! Once you click on a tutorial, for example ComplexArithmetic you will get different exercises for you to edit and once you are ready just press ctrl + enter or press button Run to check if your code is ok.

image

  • If you want to have katas locally you have all instructions to clone the environment in the following link.

Also a friend of mine Sarah Kaiser, a Quantum MVP started a book to help you to learn Quantum computing with Python and Q#, you can check it out here.

Imagen

Using Q# with Python and Jupyter just got soo much better!

Prepare the environment to work with Q# in Jupyter notebook

To work with Jupyter we need to install IQ# Jupyter kernel, which is an extension primarily used by Jupyter and Python to the .NET Core SDK that provides the core functionality for compiling and simulating Q# operations.

1 – Install Miniconda.

2 –  Once Miniconda is installed, you can use the conda command to install any other packages and create environments, etc. Lets open Anaconda Prompt (I am using Windows Terminal Preview), and type “conda” to check if everything installed correctly.

image

3 – We now need to create our environment (conda envs are especially useful, as you can specify things that are not Python packages as part of an environment (like if you needed a particular version of some .NET tooling, or the IQ# kernel that powers Python ↔ Q# interoperability)), with required packages incluiding : Jupyter notebook and IQ# (IQ# kernel to run your existing Q# Jupyter Notebooks.)

To create our environment type: conda create –n NAMEFORENV –c quantum-engineering qsharp notebook

image_thumb[6]

4 – Lets activate our environment.

image

5 – To verify installation and populate package with QDK run the following command:  python –c “import qsharp”

image_thumb[12]

6 – Type the following command to start the Jupyter notebook: “jupyter notebook” which will automatically open jupyter in your browser, if it doesn’t you can copy paste the url provided.

image_thumb[16]

7 –  Select “New” at the top right corner and select Q# to create a Jupyter notebook with a Q# Kernel.

image

8 – Let´s try the “GenerateRandom” operation we created in our previous article in VSCode.

image

I will be posting more information while i get deeper into this new world.

Take care!

Leave a Reply

Your email address will not be published. Required fields are marked *

I’m Ivana

I’m a Technology Advocate who is living proof that Technology changes lives. I started my career with Microsoft from my small city (Salta), in Argentina. Now I train people and teams globally in the powerful international language of Tech. I inspire people from all walks of life to become world citizens and “geeks” like me who dream big and achieve amazing things. As a proud woman in Tech, content creator and public speaker I love travelling, connect and create magic moments of transformation; and I learn from everyone I meet. When I am not on the road, I am home with my husband and two dogs. My adventurous spirit in my work life is echoed in my love for Disney movies like Moana and Lilo & Stitch. Who knows “how far I’ll go” on my journey, but I know the power of Technology can get me there!

Let’s connect