Xanadu Quantum Codebook is an experimental, exercise-based introduction to quantum computing using PennyLane.

Overview

Xanadu Quantum Codebook

The Xanadu Quantum Codebook is an experimental, exercise-based introduction to quantum computing using PennyLane. This repository contains all the source text and coding challenge templates in the Codebook; the Codebook itself is available at codebook.xanadu.ai.

Providing feedback and getting help

The Codebook is currently in the beta stage of development. If you find an error in the Codebook, something is not working as expected, or have other technical feedback, please open an issue in this repository.

If you are stuck on a coding exercise, or have questions about the content and material, please post a question on the PennyLane discussion forum under the "Codebook" category.

Codebook team

The Xanadu Quantum Codebook was written, developed, and reviewed by members of the Xanadu team. The current contents are the work of the following people:

Catalina Albornoz, Guillermo Alonso, Mikhail Andrenkov, Priya Angara*, Ali Asadi, Álvaro Ballon, Sanchit Bapat, Olivia Di Matteo, Paul Finlay, Alberto Fumagalli, Andrew Gardhouse, Natalie Girard, Ant Hayes, Josh Izaac, Timjan Kalajdzievski, Nathan Killoran, Jay Soni, David Wakeham*.

(* Funding support for our student authors was provided by the Mitacs Accelerate program.)

If you would like to acknowledge the Codebook in your work, please use the following format:

C. Albornoz, G. Alonso, M. Andrenkov, P. Angara, A. Asadi, A. Ballon, S. Bapat, O. Di Matteo, P. Finlay, A. Fumagalli, A. Gardhouse, N. Girard, A. Hayes, J. Izaac, T. Kalajdzievski, N. Killoran, J. Soni, D. Wakeham. (2021) Xanadu Quantum Codebook.

Comments
  • [BUG] Error in grader

    [BUG] Error in grader

    Node number

    Codercise I.14.2

    Expected behavior

    IMPLEMENT THE MULTIPLEXER
    IF STATE OF FIRST TWO QUBITS IS 01, APPLY X TO THIRD QUBIT

    qml.MultiControlledX(control_wires=[0,1], wires=2, control_values='01') The above code should result in the desired behaviour, that is, give the correct output.

    Actual behavior

    Incorrect: your circuit does not have the correct action on |01>.

    Is however, the error being raised!

    Additional information

    No response

    Source code

    No response

    Tracebacks

    No response

    • [X] I have searched existing GitHub issues to make sure the issue does not already exist.
    opened by p-j-r 5
  • [BUG] Finishing node backward will mark succeeding node incomplete

    [BUG] Finishing node backward will mark succeeding node incomplete

    Node number

    Node I

    Expected behavior

    When finishing lessons in Node A before Node I, Node A should still be marked as complete.

    Actual behavior

    Node A will get back to an incomplete state (white circle) when it was finishing before Node I.

    Additional information

    I finished Node A before Node I. Node I is marked as complete (green circle). However, Node A (which previously finished) is not anymore.

    I am not certain about other node (like if you do the lesson backward, etc.). You might have to check them as well.

    Source code

    No response

    Tracebacks

    No response

    • [X] I have searched existing GitHub issues to make sure the issue does not already exist.
    opened by rootEnginear 4
  • [BUG] Cant accept terms

    [BUG] Cant accept terms

    Node number

    T

    Expected behavior

    I scroll to the bottom, and then the accept terms button becomes active

    Actual behavior

    Accept terms never becomes active

    Additional information

    Tried with and without Ublock Origin enabled (Chrome/Windows)

    Source code

    No response

    Tracebacks

    No response

    • [X] I have searched existing GitHub issues to make sure the issue does not already exist.
    opened by 00alia00 3
  • Wrong solution Codercise I.7.3

    Wrong solution Codercise I.7.3

    Feature details

    In Codercise I.7.3, the solution accepted as correct seems to be the wrong one.

    In the explanation following the question, 2 solutions are presented as being the only possible ones, and the second one (HTTHTH) is indicated as the correct one. However, the submission for the previous question only accepts the first one (HTHTTH) as the right answer.

    I worked out the math, and can confirm that the second one (HTTHTH) is the right answer as indicated in the text but not in the accepted solution to the codercise.

    image

    Additional information

    No response

    opened by kmyali 2
  • [Bug] Error in P1.1 grader

    [Bug] Error in P1.1 grader

    Feature details

    As explained here, the grader is marking a wrong answer (Hadamard on wire 1) as correct while marking wrong the correct answer (Hadamard on wire 0).

    Additional information

    No response

    opened by CatalinaAlbornoz 2
  • Incorrect Action of RY on Computational Basis States in I.6

    Incorrect Action of RY on Computational Basis States in I.6

    Feature details

    Hi there,

    There is a small error in the left panel equation display of the action of $RY(\theta)$ on the computational basis states in I.6 (in the discussion after codercise I.6.3). The sign of the $\sin(\theta/2)$ terms is reversed.

    Note that the expressions for this are correct in the corresponding place in the right "textbook" panel (end of the solution to exercise I.6.3).

    Additional information

    No response

    opened by robertmoir 2
  • [EDIT] I1.10 Incorrect analytical expectation value

    [EDIT] I1.10 Incorrect analytical expectation value

    Feature details

    Solution to Exercise I.10.2.c is given as 3.022769, but using Wolfram Alpha to calculate the provided matrix multiplication suggests that the answer should be -0.302769 instead.

    Using Pennylane to measure

    dev = qml.device("default.qubit", wires=1)
        @qml.qnode(dev)
        def qf():
            qml.MottonenStatePreparation([4 / 5, -3 / 5 * np.e ** (1j * np.pi / 3)], 0)
            return qml.expval(qml.Hermitian(np.array([[1, -2 * 1j], [2 * 1j, 2]]), 0))
    print(qf())
    

    also yields -0.3027687752661218

    Additional information

    No response

    accepted 
    opened by paullin03 2
  • [BUG]

    [BUG]

    Node number

    I.7.3

    Expected behavior

    Not to accept my answer

    Actual behavior

    My answer HTHT was accepted.

    Additional information

    No response

    Source code

    dev = qml.device("default.qubit", wires=1)
    
    @qml.qnode(dev)
    def unitary_with_h_and_t():
        
        qml.Hadamard(wires = 0)
        qml.T(wires = 0)
        qml.Hadamard(wires = 0)
        qml.T(wires = 0)
        
        
    
        return qml.state()
    

    Tracebacks

    No response

    • [X] I have searched existing GitHub issues to make sure the issue does not already exist.
    accepted 
    opened by Boniface316 2
  • [EDIT] Minor typo in codebook text, node G.4

    [EDIT] Minor typo in codebook text, node G.4

    Node number

    Node G.4, Exercise Exercise G.4.1

    Current content

    In the solution of Exercise G.4.1, item (a):

    The first term in the equation read $\left ( U \left | u\right \rangle \right )^\dagger \left | v\right \rangle$, but there's a $U$ missing, acting on $\left | v\right \rangle$

    Expected content

    The first term in the equation should be:

    $\left ( U \left | u\right \rangle \right )^\dagger U \left | v\right \rangle$

    Or even

    $\left ( U \left | u\right \rangle \right )^\dagger \left ( U \left | v\right \rangle \right )$

    • [X] I have searched existing GitHub issues to make sure the issue does not already exist.
    accepted 
    opened by andre-juan 2
  • [EDIT] Add syntax of the required gate

    [EDIT] Add syntax of the required gate

    Node number

    Codercise I.13.4.

    Current content

    The question does not contain the actual syntax of the MultiControlledX gate.

    Expected content

    A tip/hint drop down which contains:

    qml.MultiControlledX(control_wires=[control_1, control_2], wires=target_wire, control_values=string_of_control_values)
    

    • [X] I have searched existing GitHub issues to make sure the issue does not already exist.
    accepted 
    opened by ankit27kh 2
  • T-depth = 5 in Codercise I.5.4

    T-depth = 5 in Codercise I.5.4

    Node number

    Codercise I.5.4

    Current content

    The depth of the original circuit is 8, and there are 13 combined T and T† gates. The original T-depth is 6.

    Expected content

    The original T-depth should be 5 since the second qubit has a maximum of 5 T gates in a row.

    • [X] I have searched existing GitHub issues to make sure the issue does not already exist.
    opened by SaashaJoshi 2
  • [BUG] in codercise I.1.2

    [BUG] in codercise I.1.2

    Node number

    Node I.1, codercises I.1.2

    Expected behavior

    Codercise I.1.2 should throw an error if user mistakenly submits the inner product <state_2 | state_1> instead of <state_1 | state_2>.

    Possible solution: Have grader use complex-valued states for which <state_1 | state_2> != <state_1 | state_1>

    Actual behavior

    Grader passes even if user submits answer for <state_2 | state_1>.

    Additional information

    For example, the grader passes if user inputs:

        ##################
        # YOUR CODE HERE #
        ##################
    
        # COMPUTE AND RETURN THE INNER PRODUCT
    
        return  np.vdot(state_2,state_1)
    

    or

        ##################
        # YOUR CODE HERE #
        ##################
    
        # COMPUTE AND RETURN THE INNER PRODUCT
    
        return  np.dot(state_1,np.conjugate(state_2))
    

    Source code

    No response

    Tracebacks

    No response

    Check other issues

    • [X] I have searched existing GitHub issues to make sure the issue does not already exist.
    opened by diemilio 1
  • [BUG] in codercise I.1.1

    [BUG] in codercise I.1.1

    Node number

    Node I.1, codercises I.1.1

    Expected behavior

    Codercise I.1.1 should throw an error if user normalizes state without taking the norm of the complex amplitudes.

    Possible solution: Have grader use complex-valued variables to check answers.

    Actual behavior

    Grader passes even if normalization constant is not calculated correctly (a^2 + b^2 = 1 instead of |a'|^2 + |b'|^2 = 1`).

    Additional information

    For example, the grader passes if user inputs:

        # CREATE A VECTOR [a', b'] BASED ON alpha AND beta SUCH THAT |a'|^2 + |b'|^2 = 1
        norm_psi = np.array([alpha,beta])/np.sqrt(alpha**2+beta**2)
        # RETURN A VECTOR
        return norm_psi
    

    or

        # CREATE A VECTOR [a', b'] BASED ON alpha AND beta SUCH THAT |a'|^2 + |b'|^2 = 1
        psi = np.array([alpha,beta])
        norm_psi = psi/np.sqrt(np.dot(psi,psi))
        # RETURN A VECTOR
        return norm_psi
    

    The correct implementations should be:

        # CREATE A VECTOR [a', b'] BASED ON alpha AND beta SUCH THAT |a'|^2 + |b'|^2 = 1
        norm_psi = np.array([alpha,beta])/np.sqrt(abs(alpha)**2+abs(beta)**2)
        # RETURN A VECTOR
        return norm_psi
    

    or

        # CREATE A VECTOR [a', b'] BASED ON alpha AND beta SUCH THAT |a'|^2 + |b'|^2 = 1
        psi = np.array([alpha,beta])
        norm_psi = psi/np.sqrt(np.dot(psi,psi))
        # RETURN A VECTOR
        return norm_psi
    

    Source code

    No response

    Tracebacks

    No response

    Check other issues

    • [X] I have searched existing GitHub issues to make sure the issue does not already exist.
    opened by diemilio 1
  • Typo in P3.2

    Typo in P3.2

    Feature details

    P.3.2 seems to have a typo (as detailed here) in the explanation of the desired output.

    Current: “”" Returns: [(float, float)]: a list of phase windows for 1 to 9 estimation wires “”"

    Fixed: “”" Returns: [(float, float)]: a list of phase windows for “2” to 9 estimation wires “”"

    Additional information

    No response

    opened by CatalinaAlbornoz 0
  • [BUG] in codercise P3.1

    [BUG] in codercise P3.1

    Feature details

    As detailed here, the grader is taking bound 1 and bound 2 in the reverse order. We should either change the grader, the description of the bounds or the order in which they are returned.

    Additional information

    No response

    opened by CatalinaAlbornoz 0
  • New Feature Request

    New Feature Request

    Feature details

    Is there a way I can access any code that I have done in one desktop to a laptop without having to restart my laptop?

    Additional information

    No response

    opened by erdabravest2001 1
Releases(v0.1.0)
Owner
Xanadu
Quantum Computing Powered by Light
Xanadu
Python bindings to OpenSlide

OpenSlide Python OpenSlide Python is a Python interface to the OpenSlide library. OpenSlide is a C library that provides a simple interface for readin

OpenSlide 297 Dec 21, 2022
Tampilan - Change Termux Appearance With Python

Tampilan Gambar usage pkg update && pkg upgrade pkg install git && pkg install f

Creator Lord-Botz 1 Jan 31, 2022
Demonstration that AWS IAM policy evaluation docs are incorrect

The flowchart from the AWS IAM policy evaluation documentation page, as of 2021-09-12, and dating back to at least 2018-12-27, is the following: The f

Ben Kehoe 15 Oct 21, 2022
Visualizacao-dados-dell - Repositório com as atividades desenvolvidas no curso de Visualização de Dados

📚 Descrição Neste curso da Dell trabalhamos com a visualização de dados. 🖥️ Aulas 1.1 - Explorando conjuntos de dados 1.2 - Fundamentos de visualiza

Claudia dos Anjos 1 Dec 28, 2021
DeltaPy - Tabular Data Augmentation (by @firmai)

DeltaPy⁠⁠ — Tabular Data Augmentation & Feature Engineering Finance Quant Machine Learning ML-Quant.com - Automated Research Repository Introduction T

Derek Snow 470 Dec 28, 2022
Gtech μLearn Sample_bot

Ser_bot Gtech μLearn Sample_bot Do Greet a newly joined member in a channel (random message) While adding a reaction to a message send a message to a

Jerin Paul 1 Jan 19, 2022
Pydocstringformatter - A tool to automatically format Python docstrings that tries to follow recommendations from PEP 8 and PEP 257.

Pydocstringformatter A tool to automatically format Python docstrings that tries to follow recommendations from PEP 8 and PEP 257. See What it does fo

Daniël van Noord 31 Dec 29, 2022
k3heap is a binary min heap implemented with reference

k3heap k3heap is a binary min heap implemented with reference k3heap is a component of pykit3 project: a python3 toolkit set. In this module RefHeap i

pykit3 1 Nov 13, 2021
🌱 Complete API wrapper of Seedr.cc

Python API Wrapper of Seedr.cc Table of Contents Installation How I got the API endpoints? Start Guide Getting Token Logging with Username and Passwor

Hemanta Pokharel 43 Dec 26, 2022
Example Python code for running the mango-explorer marketmaker

🥭 Mango Explorer 📖 Introduction This guide will show you how to load and run a customisable marketmaker that runs on Mango Markets using the mango-e

Blockworks Foundation 2 Apr 11, 2022
Data-science-on-gcp - Source code accompanying book: Data Science on the Google Cloud Platform, Valliappa Lakshmanan, O'Reilly 2017

data-science-on-gcp Source code accompanying book: Data Science on the Google Cloud Platform, 2nd Edition Valliappa Lakshmanan O'Reilly, Jan 2022 Bran

Google Cloud Platform 1.2k Dec 28, 2022
The blazing-fast Discord bot.

Wavy Wavy is an open-source multipurpose Discord bot built with pycord. Wavy is still in development, so use it at your own risk. Tools and services u

Wavy 7 Dec 27, 2022
Generating a report CSV and send it to an email - Python / Django Rest Framework

Generating a report in CSV format and sending it to a email How to start project. Create a folder in your machine Create a virtual environment python3

alexandre Lopes 1 Jan 17, 2022
An introduction to hikari, complete with different examples for different command handlers.

An intro to hikari This repo provides some simple examples to get you started with hikari. Contained in this repo are bots designed with both the hika

Ethan Henderson 18 Nov 29, 2022
🏆 A ranked list of awesome python developer tools and libraries. Updated weekly.

Best-of Python Developer Tools 🏆 A ranked list of awesome python developer tools and libraries. Updated weekly. This curated list contains 250 awesom

Machine Learning Tooling 646 Jan 07, 2023
This repo contains everything you'll ever need to learn/revise python basics

Python Notes/cheat sheet Simplified notes to get your Python basics right Just compare code and output side by side and feel the rush of enlightenment

Hem 5 Oct 06, 2022
BakTst_Org is a backtesting system for quantitative transactions.

BakTst_Org 中文reademe:传送门 Introduction: BakTst_Org is a prototype of the backtesting system used for BTC quantitative trading. This readme is mainly di

18 May 08, 2021
Data science Python notebooks: Deep learning (TensorFlow, Theano, Caffe, Keras), scikit-learn, Kaggle, big data (Spark, Hadoop MapReduce, HDFS), matplotlib, pandas, NumPy, SciPy, Python essentials, AWS, and various command lines.

Data science Python notebooks: Deep learning (TensorFlow, Theano, Caffe, Keras), scikit-learn, Kaggle, big data (Spark, Hadoop MapReduce, HDFS), matplotlib, pandas, NumPy, SciPy, Python essentials, A

Donne Martin 24.5k Jan 09, 2023
Python Programming (Practical) (1-25) Download 👇🏼

BCA-603 : Python Programming (Practical) (1-25) Download zip 🙂 🌟 How to run programs : Clone or download this repo to your computer. Unzip (If you d

Milan Jadav 2 Jun 02, 2022
Resource hub for Obsidian resources.

Obsidian Community Vault Welcome! This is an experimental vault that is maintained by the Obsidian community. For best results we recommend downloadin

Obsidian Community 320 Jan 02, 2023