• Stars
    star
    526
  • Rank 83,672 (Top 2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created almost 5 years ago
  • Updated 22 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Introductions to key concepts in quantum programming, as well as tutorials and implementations from cutting-edge quantum computing research.

This repository contains introductory materials on Quantum Machine Learning, as well as Python code demos using PennyLane, a cross-platform Python library for differentiable programming of quantum computers.

The content consists of three learning hubs and two additional areas:

Explore these materials on our website: https://pennylane.ai/qml. All tutorials are fully executable, and can be downloaded as Jupyter notebooks and Python scripts.

Contributing

You can contribute by submitting a demo via a pull request implementing a recent quantum computing paper/result.

Adding demos

  • Demos are written in the form of an executable Python script. Any package listed in requirements.txt and requirements_no_deps.txt you can assume is available to be imported. Matplotlib plots will be automatically rendered and displayed on the QML website.

    Note: try and keep execution time of your script to within 10 minutes.

  • If you would like to write the demo using a Jupyter notebook, you can convert the notebook to the required executable Python format by following these steps.

  • All demos should have a file name beginning with tutorial_. The python files are saved in the demonstrations directory.

  • Restructured Text sections may be anywhere within the script by beginning the comment with 79 hashes (#). These are useful for breaking up large code-blocks.

  • You may add figures within ReST comments by using the following syntax:

    ##############################################################################
    #.. figure:: ../demonstrations/<demo name>/image.png
    #    :align: center
    #    :width: 90%

    where <demo name> is a sub-directory with the name of your demo.

  • Add and select an author photo from the _static/authors folder. The image name should be as <author name>_<author surname>.<format>. If this is a new author and their image is not a headshot, store the original image as <author name>_<author surname>_original.<format> and create a cropped headshot with the aforementioned name.

  • In the same folder create a <author name>.txt file where to include the bio following this structure:

    .. bio:: <author name>
     :photo: ../_static/authors/<author name>_<author surname>.<format>
    
     <author's bio>
  • To show the bio you must add this at the end of the demo:

    ##############################################################################
    # About the author
    # ----------------
    # .. include:: ../_static/authors/<author name>.txt  
  • When complete, create a gallery link to your demo. This can be done by adding the snippet below to demos_getting-started.rst for introductory demos.

    .. gallery-item::
        :tooltip: An extended description of the demo
        :figure: demonstrations/<demo name>/thumbnail.png
        :description: :doc:`demos/tutorial_name`

    Note that here you will include the thumbnail that will appear in your demo. This image will be created by our team but for convenience in the review, add a provisional image. You should also add there a link to your demo to the table of contents, by adding to the end of the .. toctree:: in the appropriate file.

.. toctree::
    :maxdepth: 2
    :caption: Getting Started
    :hidden:

    demos/tutorial_qubit_rotation
    demos/tutorial_name

If you're unsure which file to put your demo in, choose the one you think is best, and we will work together to sort it during the review process.

  • Run your script through the Black Python formatter,

    pip install black
    black -l 100 demo_new.py
  • Finally, add the metadata. The metadata is a json file in which we will store information about the demo. In this example you will see the fields you need to fill in.

    • Make sure the file name is <name of your tutorial>.metadata.json.
    • The "id" of the author will be the same as the one you chose when creating the bio.
    • The date of publication and modification. Leave them empty in case you don't know them.
    • Choose the categories your demo fits into: "Getting Started", "Optimization", "Quantum Machine Learning", "Quantum Chemistry", "Devices and Performance", "Quantum Computing", "Quantum Hardware" or "Algorithms". Feel free to add more than one.
    • In previewImages you should simply modify the final part of the file's name to fit the name of your demo. These two images will be sent to you once the review process begins.
    • relatedContent refers to the demos related to yours. You will have to put the corresponding id and set the weight to 1.0.
    • If there is any doubt with any field, do not hesitate to post a comment to the reviewer of your demo.

and you are ready to submit a pull request!

If your demo uses the latest release of PennyLane, simply make your PR against the master branch. If you instead require the cutting-edge development versions of PennyLane or any relevant plugins, make your PR against the dev branch instead.

Tutorial guidelines

While you are free to be as creative as you like with your demo, there are a couple of guidelines to keep in mind.

  • Submissions should include your name (and optionally email) at the top under the title.

  • All contributions must be made under the Apache 2.0 license.

  • The title should be clear and concise, and if based on a paper it should be similar to the paper that is being implemented.

  • All demos should include a summary below the title. The summary should be 1-3 sentences that makes clear the goal and outcome of the demo, and links to any papers/resources used.

  • Code should be clearly commented and explained, either as a ReST-formatted comment or a standard Python comment.

  • Thumbnails should be legible, interesting, and unique --- but not too busy! Any included text should be minimal and legible.

  • If your content contains random variables/outputs, a fixed seed should be set for reproducibility.

  • All content must be original or free to reuse subject to license compatibility. For example, if you are implementing someone else's research, reach out first to recieve permission to reproduce exact figures. Otherwise, avoid direct screenshots from papers, and instead refer to figures in the paper within the text.

  • All submissions must pass code review before being merged into the repository.

Building

To build the website locally, simply run make html. The rendered HTML files will now be available in _build/html. Open _build/html/index.html to browse the built site locally.

Note that the above command may take some time, as all demos will be executed and built! Once built, only modified demos will be re-executed/re-built.

Alternatively, you may run make html-norun to build the website without executing demos, or build only a single demo using the following command:

sphinx-build -D sphinx_gallery_conf.filename_pattern=tutorial_QGAN\.py -b html . _build

where tutorial_QGAN should be replaced with the name of the demo to build.

Building and running locally on Mac (M1)

To install dependencies on an M1 Mac and build the QML website, the following instructions may be useful.

  • If python3 is not currently installed, we recommend you install via Homebrew:

    brew install python
  • Install each package in requirements-norun.txt by running

    pip3 install -r requirements-norun.txt

    Alternatively, you can do this in a new virtual environment using

    python -m venv [venv_name]
    cd [venv_name] && source bin/activate
    pip install -r requirements-norun.txt

Once this is complete, you should be able to build the website using make html-norun. If this succeeds, the build folder should be populated with files. Open index.html in your browser to view the built site.

If you are running into the error message

command not found: sphinx-build

you may need to make the following change:

  • In the Makefile change SPHINXBUILD = sphinx-build to SPHINXBUILD = python3 -m sphinx.cmd.build.

If you are running into the error message

ModuleNotFoundError: No module named 'the-module-name'

you may need to install the module manually:

pip3 install the-module-name

Support

If you are having issues, please let us know by posting the issue on our GitHub issue tracker.

We are committed to providing a friendly, safe, and welcoming environment for all. Please read and respect the Code of Conduct.

License

The materials and demos in this repository are free and open source, released under the Apache License, Version 2.0.

The file custom_directives.py is available under the BSD 3-Clause License with Copyright (c) 2017, Pytorch contributors.

More Repositories

1

pennylane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Python
2,241
star
2

pennylane-qiskit

The PennyLane-Qiskit plugin integrates the Qiskit quantum computing framework and IBM Q with PennyLane.
Python
181
star
3

catalyst

A JIT compiler for hybrid quantum programs in PennyLane
Python
91
star
4

pennylane-lightning

The PennyLane-Lightning plugin provides a fast state-vector simulator written in C++ for use with PennyLane
C++
82
star
5

pennylane-cirq

The PennyLane-Cirq plugin integrates Google's Cirq software library with with PennyLane's quantum machine learning capabilities.
Python
49
star
6

pennylane-lightning-gpu

GPU enabled Lightning simulator for accelerated circuit simulation. See https://github.com/PennyLaneAI/pennylane-lightning for all future development of this project.
C++
49
star
7

pennylane-rigetti

This PennyLane plugin allows the Rigetti Forest QPUs, QVM, and wavefunction simulator to optimize quantum circuits.
Python
37
star
8

pennylane-sf

The PennyLane-SF plugin integrates Xanadu's Strawberry Fields photonic quantum simulators and hardware with PennyLane's quantum machine learning capabilities.
Python
37
star
9

pennylane-qulacs

The PennyLane-Qulacs plugin integrates the Qulacs quantum computing framework with PennyLane's quantum machine learning capabilities.
Python
27
star
10

generative-quantum-states

Official code for the paper "Predicting Properties of Quantum Systems with Conditional Generative Models"
Jupyter Notebook
20
star
11

pennylane-honeywell

The PennyLane-Honeywell plugin integrates Honeywell Quantum Solutions' ion-trap quantum computing hardware with with PennyLane's quantum machine learning capabilities.
Python
19
star
12

PennyLane-qsharp

This plugin allows the full state simulator from the Microsoft Quantum Development Toolkit devices to work with PennyLane.
Python
16
star
13

pennylane-pq

Contains the PennyLane ProjectQ plugin. This plugin provides three devices to work with PennyLane - the ProjectQ IBM device, the ProjectQ quantum simulator, and the ProjectQ classical simulator.
Python
16
star
14

pennylane-lightning-kokkos

Kokkos enabled Lightning simulator for accelerated circuit simulation. See https://github.com/PennyLaneAI/pennylane-lightning for all future development of this project.
C++
15
star
15

PennyLane-IonQ

This PennyLane plugin allows IonQ simulators/hardware to be used as PennyLane devices.
Python
9
star
16

plugin-test-matrix

Scheduled integration tests for the official plugins
Python
9
star
17

lightning-on-hpc

"Hybrid quantum programming with PennyLane Lightning on HPC platforms" accompanying data and workloads
Jupyter Notebook
8
star
18

pennylane-aqt

The PennyLane-AQT plugin integrates Alpine Quantum Technologies' ion-trap quantum computing hardware with with PennyLane's quantum machine learning capabilities.
Python
8
star
19

pennylane.ai

The website for PennyLane
HTML
7
star
20

DatasetsSource

Repo containing the datasets source code.
Python
7
star
21

pennylane-orquestra

The PennyLane-Orquestra plugin integrates the Orquestra workflow management system with PennyLane
Python
6
star
22

diastatic-malt

A tool for source-to-source transformations and operator overloading in Python
Python
5
star
23

Lightning-Unification

This repository will host the Lightning unification work.
C++
3
star
24

benchmark

Benchmarks the PennyLane library using airspeed velocity.
Python
3
star
25

pennylane-sphinx-theme

Sphinx theme for PennyLaneAI repositories
Python
2
star
26

pulse-benchmarks

Some basic benchmarks for `pennylane.pulse`
Jupyter Notebook
2
star
27

differentiable-quantum-transforms

Jupyter Notebook
1
star
28

automation

This repository contains automation code for version bumping PL-plugins
Python
1
star