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
Docov - Light-weight, recursive docstring coverage analysis for python modules

docov Light-weight, recursive docstring coverage analysis for python modules. Ov

Richard D. Paul 3 Feb 04, 2022
Yu-Gi-Oh! Master Duel translation script

Yu-Gi-Oh! Master Duel translation script

715 Jan 08, 2023
My solutions to the Advent of Code 2021 problems in Go and Python 🎄

🎄 Advent of Code 2021 🎄 Summary Advent of Code is an annual Advent calendar of programming puzzles. This year I am doing it in Go and Python. Runnin

Orfeas Antoniou 16 Jun 16, 2022
Course materials for: Geospatial Data Science

Course materials for: Geospatial Data Science These course materials cover the lectures for the course held for the first time in spring 2022 at IT Un

Michael Szell 266 Jan 02, 2023
Template repo to quickly make a tested and documented GitHub action in Python with Poetry

Python + Poetry GitHub Action Template Getting started from the template Rename the src/action_python_poetry package. Globally replace instances of ac

Kevin Duff 89 Dec 25, 2022
Documentation for GitHub Copilot

NOTE: GitHub Copilot discussions have moved to the Copilot Feedback forum. GitHub Copilot Welcome to the GitHub Copilot user community! In this reposi

GitHub 21.3k Dec 28, 2022
Soccerdata - Efficiently scrape soccer data from various sources

SoccerData is a collection of wrappers over soccer data from Club Elo, ESPN, FBr

Pieter Robberechts 195 Jan 04, 2023
CoderByte | Practice, Tutorials & Interview Preparation Solutions|

CoderByte | Practice, Tutorials & Interview Preparation Solutions This repository consists of solutions to CoderByte practice, tutorials, and intervie

Eda AYDIN 6 Aug 09, 2022
Żmija is a simple universal code generation tool.

Żmija Żmija is a simple universal code generation tool. It is intended to be used as a means to generate code that is both efficient and easily mainta

Adrian Samoticha 2 Nov 23, 2021
Searches a document for hash tags. Support multiple natural languages. Works in various contexts.

ht-getter Searches a document for hash tags. Supports multiple natural languages. Works in various contexts. This package uses a non-regex approach an

Rairye 1 Mar 01, 2022
DocumentPy is a Python application that runs in a command-line interface environment, made for creating HTML documents.

DocumentPy DocumentPy is a Python application that runs in a command-line interface environment, made for creating HTML documents. Usage DocumentPy, a

Lotus 0 Jul 15, 2021
Hasköy is an open-source variable sans-serif typeface family

Hasköy Hasköy is an open-source variable sans-serif typeface family. Designed with powerful opentype features and each weight includes latin-extended

67 Jan 04, 2023
Sphinx Bootstrap Theme

Sphinx Bootstrap Theme This Sphinx theme integrates the Bootstrap CSS / JavaScript framework with various layout options, hierarchical menu navigation

Ryan Roemer 584 Nov 16, 2022
Materi workshop "Light up your Python!" Himpunan Mahasiswa Sistem Informasi Fakultas Ilmu Komputer Universitas Singaperbangsa Karawang, 4 September 2021 (Online via Zoom).

Workshop Python UNSIKA 2021 Materi workshop "Light up your Python!" Himpunan Mahasiswa Sistem Informasi Fakultas Ilmu Komputer Universitas Singaperban

Eka Putra 20 Mar 24, 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

1 Jan 06, 2022
A set of Python libraries that assist in calling the SoftLayer API.

SoftLayer API Python Client This library provides a simple Python client to interact with SoftLayer's XML-RPC API. A command-line interface is also in

SoftLayer 155 Sep 20, 2022
Python solutions to solve practical business problems.

Python Business Analytics Also instead of "watching" you can join the link-letter, it's already being sent out to about 90 people and you are free to

Derek Snow 357 Dec 26, 2022
PowerApps-docstring is a console based, pipeline ready application that automatically generates user and technical documentation for Power Apps.

powerapps-docstring PowerApps-docstring is a console based, pipeline ready application that automatically generates user and technical documentation f

Sebastian Muthwill 30 Nov 23, 2022
Plotting and analysis tools for ARTIS simulations

Artistools Artistools is collection of plotting, analysis, and file format conversion tools for the ARTIS radiative transfer code. Installation First

ARTIS Monte Carlo Radiative Transfer 8 Nov 07, 2022
A Json Schema Generator

JSON Schema Generator Author : Eru Michael About A Json Schema Generator. This is a generic program that: Reads a JSON file similar to what's present

1 Nov 10, 2021