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
In this Github repository I will share my freqtrade files with you. I want to help people with this repository who don't know Freqtrade so much yet.

My Freqtrade stuff In this Github repository I will share my freqtrade files with you. I want to help people with this repository who don't know Freqt

Simon Kebekus 104 Dec 31, 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
Gaphor is the simple modeling tool

Gaphor Gaphor is a UML and SysML modeling application written in Python. It is designed to be easy to use, while still being powerful. Gaphor implemen

Gaphor 1.3k Jan 03, 2023
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
VSCode extension that generates docstrings for python files

VSCode Python Docstring Generator Visual Studio Code extension to quickly generate docstrings for python functions. Features Quickly generate a docstr

Nils Werner 506 Jan 03, 2023
Source Code for 'Practical Python Projects' (video) by Sunil Gupta

Apress Source Code This repository accompanies %Practical Python Projects by Sunil Gupta (Apress, 2021). Download the files as a zip using the green b

Apress 2 Jun 01, 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 03, 2023
AiiDA plugin for the HyperQueue metascheduler.

aiida-hyperqueue WARNING: This plugin is still in heavy development. Expect bugs to pop up and the API to change. AiiDA plugin for the HyperQueue meta

AiiDA team 3 Jun 19, 2022
Seamlessly integrate pydantic models in your Sphinx documentation.

Seamlessly integrate pydantic models in your Sphinx documentation.

Franz Wöllert 71 Dec 26, 2022
Workbench to integrate pyoptools with freecad, that means basically optics ray tracing capabilities for FreeCAD.

freecad-pyoptools Workbench to integrate pyoptools with freecad, that means basically optics ray tracing capabilities for FreeCAD. Requirements It req

Combustión Ingenieros SAS 12 Nov 16, 2022
Generates, filters, parses, and cleans data regarding the financial disclosures of judges in the American Judicial System

This repository contains code that gets data regarding financial disclosures from the Court Listener API main.py: contains driver code that interacts

Ali Rastegar 2 Aug 06, 2022
A curated list of awesome mathematics resources

A curated list of awesome mathematics resources

Cyrille Rossant 6.7k Jan 05, 2023
💻An open-source eBook with 101 Linux commands that everyone should know

This is an open-source eBook with 101 Linux commands that everyone should know. No matter if you are a DevOps/SysOps engineer, developer, or just a Linux enthusiast, you will most likely have to use

Ashfaque Ahmed 0 Oct 29, 2022
Near Zero-Overhead Python Code Coverage

Slipcover: Near Zero-Overhead Python Code Coverage by Juan Altmayer Pizzorno and Emery Berger at UMass Amherst's PLASMA lab. About Slipcover Slipcover

PLASMA @ UMass 325 Dec 28, 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
Spin-off Notice: the modules and functions used by our research notebooks have been refactored into another repository

Fecon235 - Notebooks for financial economics. Keywords: Jupyter notebook pandas Federal Reserve FRED Ferbus GDP CPI PCE inflation unemployment wage income debt Case-Shiller housing asset portfolio eq

Adriano 825 Dec 27, 2022
Fully reproducible, Dockerized, step-by-step, tutorial on how to mock a "real-time" Kafka data stream from a timestamped csv file. Detailed blog post published on Towards Data Science.

time-series-kafka-demo Mock stream producer for time series data using Kafka. I walk through this tutorial and others here on GitHub and on my Medium

Maria Patterson 26 Nov 15, 2022
DataAnalysis: Some data analysis projects in charles_pikachu

DataAnalysis DataAnalysis: Some data analysis projects in charles_pikachu You can star this repository to keep track of the project if it's helpful fo

9 Nov 04, 2022
A Python package develop for transportation spatio-temporal big data processing, analysis and visualization.

English 中文版 TransBigData Introduction TransBigData is a Python package developed for transportation spatio-temporal big data processing, analysis and

Qing Yu 251 Jan 03, 2023
Show Rubygems description and annotate your code right from Sublime Text.

Gem Description for Sublime Text Show Rubygems description and annotate your code. Just mouse over your Gemfile's gem definitions to show the popup. s

Nando Vieira 2 Dec 19, 2022