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
freeCodeCamp Scientific Computing with Python Project for Certification.

Polygon_Area_Calculator freeCodeCamp Python Project freeCodeCamp Scientific Computing with Python Project for Certification. In this project you will

Rajdeep Mondal 1 Dec 23, 2021
layout-parser 3.4k Dec 30, 2022
Documentation generator for C++ based on Doxygen and mosra/m.css.

mosra/m.css is a Doxygen-based documentation generator that significantly improves on Doxygen's default output by controlling some of Doxygen's more unruly options, supplying it's own slick HTML+CSS generation and adding a fantastic live search feature.

Mark Gillard 109 Dec 7, 2022
Dev Centric Tools for Mkdocs Based Documentation

docutools MkDocs Documentation Tools For Developers This repo is providing a set of plugins for mkdocs material compatible documentation. It is meant

Axiros GmbH 14 Sep 10, 2022
Fast syllable estimation library based on pattern matching.

Syllables: A fast syllable estimator for Python Syllables is a fast, simple syllable estimator for Python. It's intended for use in places where speed

ProseGrinder 26 Dec 14, 2022
A document format conversion service based on Pandoc.

reformed Document format conversion service based on Pandoc. Usage The API specification for the Reformed server is as follows: GET /api/v1/formats: L

David Lougheed 3 Jul 18, 2022
Explicit, strict and automatic project version management based on semantic versioning.

Explicit, strict and automatic project version management based on semantic versioning. Getting started End users Semantic versioning Project version

Dmytro Striletskyi 6 Jan 25, 2022
A simple document management REST based API for collaboratively interacting with documents

documan_api A simple document management REST based API for collaboratively interacting with documents.

Shahid Yousuf 1 Jan 22, 2022
This repo provides a package to automatically select a random seed based on ancient Chinese Xuanxue

?? Random Luck Deep learning is acturally the alchemy. This repo provides a package to automatically select a random seed based on ancient Chinese Xua

Tong Zhu(朱桐) 33 Jan 3, 2023
script to calculate total GPA out of 4, based on input gpa.csv

gpa_calculator script to calculate total GPA out of 4 based on input gpa.csv to use, create a total.csv file containing only one integer showing the t

Mohamad Bastin 1 Feb 7, 2022
Code for our SIGIR 2022 accepted paper : P3 Ranker: Mitigating the Gaps between Pre-training and Ranking Fine-tuning with Prompt-based Learning and Pre-finetuning

P3 Ranker Implementation for our SIGIR2022 accepted paper: P3 Ranker: Mitigating the Gaps between Pre-training and Ranking Fine-tuning with Prompt-bas

null 14 Jan 4, 2023
Generate YARA rules for OOXML documents using ZIP local header metadata.

apooxml Generate YARA rules for OOXML documents using ZIP local header metadata. To learn more about this tool and the methodology behind it, check ou

MANDIANT 34 Jan 26, 2022
This is a tool to make easier brawl stars modding using csv manipulation

Brawler Maker : Modding Tool for Brawl Stars This is a tool to make easier brawl stars modding using csv manipulation if you want to support me, just

null 6 Nov 16, 2022
This repository outlines deploying a local Kubeflow v1.3 instance on microk8s and deploying a simple MNIST classifier using KFServing.

Zero to Inference with Kubeflow Getting Started This repository houses all of the tools, utilities, and example pipeline implementations for exploring

Ed Henry 3 May 18, 2022
A swagger tool for tornado, using python to write api doc!

SwaggerDoc About A swagger tool for tornado, using python to write api doc! Installation pip install swagger-doc Quick Start code import tornado.ioloo

aaashuai 1 Jan 10, 2022
A Python library for setting up projects using tabular data.

A Python library for setting up projects using tabular data. It can create project folders, standardize delimiters, and convert files to CSV from either individual files or a directory.

null 0 Dec 13, 2022
Quick tutorial on orchest.io that shows how to build multiple deep learning models on your data with a single line of code using python

Deep AutoViML Pipeline for orchest.io Quickstart Build Deep Learning models with a single line of code: deep_autoviml Deep AutoViML helps you build te

Ram Seshadri 6 Oct 2, 2022
A simple USI Shogi Engine written in python using python-shogi.

Revengeshogi My attempt at creating a USI Shogi Engine in python using python-shogi. Current State of Engine Currently only generating random moves us

null 1 Jan 6, 2022
Repository for tutorials, examples and starter scripts for using the MTU HPC cluster

MTU-HPC-Starter Repository for tutorials, examples and starter scripts for using the MTU HPC cluster Connecting to the MTU HPC cluster Within the coll

null 1 Jan 31, 2022