Skip to content

Commit

Permalink
readme for QPUs
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamari committed Sep 13, 2019
1 parent b847545 commit 820652b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions quantum_processors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

## High-resolution image classification with real quantum computers.
This folder contains the code that has been used in the paper [1] to experimentally classify high-resolution images of _ants_ and _bees_ with real quantum processors provided by IBM and Rigetti.

The model is a hybrid neural network composed of a classical block (ResNet18) and a variational "dressed quantum circuit" [1], which has been numerically optimized according to the classical-to-quantum (CQ) transfer learning paradigm.

This code can be used to test the optimized model with two alternative quantum processing units (QPUs):
1. Rigetti Aspen-4-4Q-A.
2. IBM Q 5, Tenerife (ibmq4x).

![Figure](static/realQPUs.png)

## Contents
* `test_on_QPU.py`: Python script to test the hybrid classical-quantum image classifier with IBM or Rigetti quantum processors.

* `quantum_weights.pt`: pre-trained model loaded by `test_on_QPU.py` to initialize the variational parameters of the hybrid network.

## Usage and examples

To test the model with the Rigetti backend:

1. Make sure to satisfy all requirements (see next section).
2. Login to the a QVM provided by Rigetti.
3. Download or clone the repository in the QVM.
4. Download the _Hymenoptera_ dataset as described in the main README file of the repo.
5. Edit the file `test_on_QPU.py` and set `backend = 'rigetti'`.
6. Run the command `python3 test_on_QPU.py`.

To test the model with the IBM backend:

1. Make sure to satisfy all requirements (see next section).
2. Download or clone the repository.
3. Download the _Hymenoptera_ dataset as described in the main README file the repo.
4. Edit the local file `test_on_QPU.py` and set `backend = 'ibm'`.
4. Moreover, set your personal IBM token by editing `token = '<your token>'`.
5. Run the command `python3 test_on_QPU.py`.

## Requirements

Testing the model with the Rigetti backend requires having a Rigetti QCS account with access to a remote quantum virtual machine (QVM). In the QVM, the Python library PennyLane should be installed together with the associated PyTorch and Rigetti plugins.

Testing the model with the IBM backend requires having an IBM Q Experience account with access to a remote quantum virtual machine (QVM). In the QVM, the Python library PennyLane should be installed together with the associated PyTorch and Rigetti plugins.
Binary file added static/realQPUs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 820652b

Please sign in to comment.