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
Easy OpenAPI specs and Swagger UI for your Flask API

Flasgger Easy Swagger UI for your Flask API Flasgger is a Flask extension to extract OpenAPI-Specification from all Flask views registered in your API

Flasgger 3.1k Jan 05, 2023
Convert excel xlsx file's table to csv file, A GUI application on top of python/pyqt and other opensource softwares.

Convert excel xlsx file's table to csv file, A GUI application on top of python/pyqt and other opensource softwares.

David A 0 Jan 20, 2022
NetBox plugin that stores configuration diffs and checks templates compliance

Config Officer - NetBox plugin NetBox plugin that deals with Cisco device configuration (collects running config from Cisco devices, indicates config

77 Dec 21, 2022
Fast, efficient Blowfish cipher implementation in pure Python (3.4+).

blowfish This module implements the Blowfish cipher using only Python (3.4+). Blowfish is a block cipher that can be used for symmetric-key encryption

Jashandeep Sohi 41 Dec 31, 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 02, 2022
Collection of Summer 2022 tech internships!

Collection of Summer 2022 tech internships!

Pitt Computer Science Club (CSC) 15.6k Jan 03, 2023
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
Fun interactive program to sort a list :)

LHD-Build-Sort-a-list Fun interactive program to sort a list :) Inspiration LHD Build Write a script to sort a list. What it does It is a menu driven

Ananya Gupta 1 Jan 15, 2022
Preview title and other information about links sent to chats.

Link Preview A small plugin for Nicotine+ to display preview information like title and description about links sent in chats. Plugin created with Nic

Nick 0 Sep 05, 2021
Always know what to expect from your data.

Great Expectations Always know what to expect from your data. Introduction Great Expectations helps data teams eliminate pipeline debt, through data t

Great Expectations 7.8k Jan 05, 2023
A curated list of awesome tools for Sphinx Python Documentation Generator

Awesome Sphinx (Python Documentation Generator) A curated list of awesome extra libraries, software and resources for Sphinx (Python Documentation Gen

Hyunjun Kim 831 Dec 27, 2022
A Python validator for SHACL

pySHACL A Python validator for SHACL. This is a pure Python module which allows for the validation of RDF graphs against Shapes Constraint Language (S

RDFLib 187 Dec 29, 2022
Create docsets for Dash.app-compatible API browser.

doc2dash: Create Docsets for Dash.app and Clones doc2dash is an MIT-licensed extensible Documentation Set generator intended to be used with the Dash.

Hynek Schlawack 498 Dec 30, 2022
JMESPath is a query language for JSON.

JMESPath JMESPath (pronounced "james path") allows you to declaratively specify how to extract elements from a JSON document. For example, given this

1.7k Dec 31, 2022
A fast time mocking alternative to freezegun that wraps libfaketime.

python-libfaketime: fast date/time mocking python-libfaketime is a wrapper of libfaketime for python. Some brief details: Linux and OS X, Pythons 3.5

Simon Weber 68 Jun 10, 2022
Repository for learning Python (Python Tutorial)

Repository for learning Python (Python Tutorial) Languages and Tools 🧰 Overview 📑 Repository for learning Python (Python Tutorial) Languages and Too

Swiftman 2 Aug 22, 2022
Paper and Code for "Curriculum Learning by Optimizing Learning Dynamics" (AISTATS 2021)

Curriculum Learning by Optimizing Learning Dynamics (DoCL) AISTATS 2021 paper: Title: Curriculum Learning by Optimizing Learning Dynamics [pdf] [appen

Tianyi Zhou 15 Dec 06, 2022
More detailed upload statistics for Nicotine+

More Upload Statistics A small plugin for Nicotine+ 3.1+ to create more detailed upload statistics. ⚠ No data previous to enabling this plugin will be

Nick 1 Dec 17, 2021
graphical orbitational simulation of solar system planets with real values and physics implemented so you get a nice elliptical orbits. you can change timestamp value or scale from source code idc.

solarSystemOrbitalSimulation graphical orbitational simulation of solar system planets with real values and physics implemented so you get a nice elli

Mega 3 Mar 03, 2022
Quickly download, clean up, and install public datasets into a database management system

Finding data is one thing. Getting it ready for analysis is another. Acquiring, cleaning, standardizing and importing publicly available data is time

Weecology 274 Jan 04, 2023