Readme and Documentation update (#65)

This commit is contained in:
Ismael Faro Sertage 2017-09-12 15:48:40 -04:00 committed by Juan Gomez
parent 8c80c6edaf
commit 79b5dc26dd
19 changed files with 1405 additions and 1222 deletions

147
README.md Normal file
View File

@ -0,0 +1,147 @@
# Quantum Information Software Kit (QISKit)
[![Build Status](https://travis-ci.org/QISKit/qiskit-sdk-py.svg?branch=master)](https://travis-ci.org/QISKit/qiskit-sdk-py)
The Quantum Information Software Kit (**QISKit** for short) is a software development kit (SDK) for working with [OpenQASM](https://github.com/QISKit/qiskit-openqasm) and the [IBM Q experience (QX)](https://quantumexperience.ng.bluemix.net/).
Use **QISKit** to create quantum computing programs, compile them, and execute them on one of several backends (online Real Quantum Processors, online Simulators, and local Simulators). For the online backends, QISKit uses our [python API client](https://github.com/QISKit/qiskit-api-py) to connect to the IBM Q experience.
**We use GitHub issues for tracking requests and bugs. Please see the** [IBM Q experience community](https://quantumexperience.ng.bluemix.net/qx/community) **for questions and discussion.** **If you'd like to contribute to QISKit, please take a look at our** [contribution guidelines](CONTRIBUTING.rst).
Links to Sections:
* [Installation](#installation)
* [Creating your first Quantum Program](#creating-your-first-quantum-program)
* [More Information](#more-information)
* [Authors](#authors-alphabetical)
* [License](#license)
## Installation
### Dependencies
At least [Python 3.5 or later](https://www.python.org/downloads/) is needed for using QISKit. In addition, [Jupyter Notebooks](https://jupyter.readthedocs.io/en/latest/install.html) is recommended for interacting with the tutorials.
For this reason we recomend installing [Anaconda 3](https://www.continuum.io/downloads) python distribution, as it comes with all of these dependencies pre-installed.
In addition, a basic understanding of quantum information is very helpful when interacting with QISKit. If you're new to quantum, start with our [User Guides](https://github.com/QISKit/ibmqx-user-guides)!
### PIP Installation
For those more familiar with python, the fastest way to install QISKit is by using the PIP tool (a python package manager):
```
pip install qiskit
```
### Source Installation
An alternative method is to clone the QISKit SDK repository onto your local machine, and change into the cloned directory:
#### Manual download
Select the "Clone or download" button at the top of this webpage (or from the URL shown in the git clone command), unzip the file if needed, and change into **qiskit-sdk-py folder** in a terminal window.
#### Git download
Or, if you have Git installed, run the following commands:
```
git clone https://github.com/QISKit/qiskit-sdk-py
cd qiskit-sdk-py
```
#### Setup you enviroment
We recomend using python virtual environments to improve your experience. Refer to our [Environment Setup documentation](doc/install.rst#3.1-Setup-the-environment) for more information.
## Creating your first Quantum Program
Now that the SDK is installed, it's time to begin working with QISKit.
We are ready to try out some QASM examples, which runs via the local simulator.
This is a simple superpesition example.
```
from qiskit import QuantumProgram
# Creating Programs create your first QuantumProgram object instance.
Q_program = QuantumProgram()
# Creating Registers create your first Quantum Register called "qr" with 2 qubits
qr = Q_program.create_quantum_register("qr", 2)
# create your first Classical Register called "cr" with 2 bits
cr = Q_program.create_classical_register("cr", 2)
# Creating Circuits create your first Quantum Circuit called "qc" involving your Quantum Register "qr" # and your Classical Register "cr"
qc = Q_program.create_circuit("superposition", [qr], [cr])
# add the H gate in the Qubit 0, we put this Qubit in superposition
qc.h(qr[0])
# add measure to see the state
qc.measure(qr, cr)
# Compiled and execute in the local_qasm_simulator
result = Q_program.execute(["superposition"], backend='local_qasm_simulator', shots=1024)
# Show the results
print(result)
print(result.get_data("superposition"))
```
In this case, the output will be:
```
COMPLETED
{'00': 509, '11': 515}
```
You can also use QISKit to execute your code on a [real Quantum Chip](https://github.com/QISKit/ibmqx-backend-information).
First, get your API token:
- Create an `IBM Q experience <https://quantumexperience.ng.bluemix.net>`__ account if you haven't already done so
- Get an API token from the IBM Q experience website under “My Account” > “Personal Access Token”
This API token allows you to execute your programs into the IBM Q experience backends. [Example](doc/example_real_backend.rst).
More details on this and more so in [our QISKit documentation](doc/qiskit.rst).
### Next Steps
Now you're set up and ready to check out some of the other examples from our [Tutorials](https://github.com/QISKit/qiskit-tutorial) repository. Start with the [index tutorial](https://github.com/QISKit/qiskit-tutorial/blob/master/index.ipynb) and then go to the [Getting Started example](https://github.com/QISKit/qiskit-tutorial/blob/002d054c72fc59fc5009bb9fa0ee393e15a69d07/1_introduction/getting_started.ipynb). If you already have [Jupyter Notebooks installed](https://jupyter.readthedocs.io/en/latest/install.html), you can copy and modify the notebooks to create your own experiments.
To install the tutorials as part of the QISKit SDK, see the following installation details [installation details](doc/install.rst#Install-Jupyter-based-tutorials). Complete SDK documentation can be found in the [*doc* directory](doc/qiskit.rst).
## More Information
For more information on how to use QISKit, tutorial examples, and other helpful links, take a look at these resources:
* **[User Guides](https://github.com/QISKit/ibmqx-user-guides)**,
a good starting place for learning about quantum information and computing
* **[Tutorials](https://github.com/QISKit/qiskit-tutorial)**,
for example notebooks, start with the [index](https://github.com/QISKit/qiskit-tutorial/blob/master/index.ipynb) and [Getting Started Jupyter notebook](https://github.com/QISKit/qiskit-tutorial/blob/002d054c72fc59fc5009bb9fa0ee393e15a69d07/1_introduction/getting_started.ipynb)
* **[OpenQASM](https://github.com/QISKit/openqasm)**,
for additional information and examples of QASM code
* **[IBM Quantum Experience Composer](https://quantumexperience.ng.bluemix.net/qx/editor)**,
a GUI for interacting with real and simulated quantum computers
* **[QISkit Python API](https://github.com/QISKit/qiskit-api-py)**, an API to use the IBM Quantum Experience in Python
QISKit was originally developed by researchers and developers on the [IBM-Q](http://www.research.ibm.com/ibm-q/) Team at [IBM Research](http://www.research.ibm.com/), with the aim of offering a high level development kit to work with quantum computers.
Visit the [IBM Q experience community](https://quantumexperience.ng.bluemix.net/qx/community) for questions and discussions on QISKit and quantum computing more broadly. If you'd like to contribute to QISKit, please take a look at our [contribution guidelines](CONTRIBUTING.rst).
## Authors (alphabetical)
Jim Challenger, Andrew Cross, Ismael Faro, Jay Gambetta, Juan Gomez, Paco Martin, Antonio Mezzacapo, Jesus Perez, and John Smolin, Erick Winston, Chris Wood.
In future releases, anyone who contributes with code to this project is welcome to include their name here.
## License
This project uses the [Apache License Version 2.0 software license](https://www.apache.org/licenses/LICENSE-2.0).

View File

@ -1,265 +0,0 @@
Quantum Information Software Kit (QISKit)
=========================================
|Build Status|
Python software development kit (SDK) for working
with OpenQASM and the IBM Q experience (QX).
Philosophy
----------
The basic concept of our quantum program is an array of quantum
circuits. The program workflow consists of three stages: Build, Compile,
and Run. Build allows you to make different quantum circuits that
represent the problem you are solving; Compile allows you to rewrite
them to run on different backends (simulators/real chips of different
quantum volumes, sizes, fidelity, etc); and Run launches the jobs. After
the jobs have been run, the data is collected. There are methods for
putting this data together, depending on the program. This either gives
you the answer you wanted or allows you to make a better program for the
next instance.
Organization
------------
Python example programs can be found in the *examples* directory, and test scripts are
located in *test*. The *qiskit* directory is the main module of the SDK.
Structure
---------
Programming interface
~~~~~~~~~~~~~~~~~~~~~
The *qiskit* directory is the main Python module and contains the
programming interface objects *QuantumProgram*, *QuantumRegister*,
*ClassicalRegister*, and *QuantumCircuit*.
At the highest level, users construct a *QuantumProgram* to create,
modify, compile, and execute a collection of quantum circuits. Each
*QuantumCircuit* has a set of data registers, each of type
*QuantumRegister* or *ClassicalRegister*. Methods of these objects are
used to apply instructions that define the circuit. The *QuantumCircuit*
can then generate **OpenQASM** code that can flow through other
components in the *qiskit* directory.
The *extensions* directory extends quantum circuits as needed to support
other gate sets and algorithms. Currently there is a *standard*
extension defining some typical quantum gates.
Internal modules
~~~~~~~~~~~~~~~~
The directory also contains internal modules that are still under
development:
- a *qasm* module for parsing **OpenQASM** circuits
- an *unroll* module to interpret and "unroll" **OpenQASM** to a target
gate basis (expanding gate subroutines and loops as needed)
- a *circuit* module for working with circuits as graphs
- a *mapper* module for mapping all-to-all circuits to run on devices
with fixed couplings
Quantum circuits flow through the components as follows. The programming
interface is used to generate **OpenQASM** circuits. **OpenQASM**
source, as a file or string, is passed into a *Qasm* object, whose
*parse* method produces an abstract syntax tree (**AST**). The **AST**
is passed to an *Unroller* that is attached to an *UnrollerBackend*.
There is a *PrinterBackend* for outputting text, a *SimulatorBackend*
for outputting simulator input data for the local simulators, and a
*CircuitBackend* for constructing *Circuit* objects. The *Circuit*
object represents an "unrolled" **OpenQASM** circuit as a directed
acyclic graph (**DAG**). The *Circuit* provides methods for
representing, transforming, and computing properties of a circuit and
outputting the results again as **OpenQASM**. The whole flow is used by
the *mapper* module to rewrite a circuit to execute on a device with
fixed couplings given by a *CouplingGraph*.
The four circuit representations and how they are currently transformed
into each other are summarized in this figure:
.. image:: images/circuit_representations.png
:width: 200px
:align: center
Several unroller backends and their outputs are summarized here:
.. image:: images/unroller_backends.png
:width: 200px
:align: center
Installation and setup
----------------------
1. Get the tools
~~~~~~~~~~~~~~~~
You'll need:
- Install `Python 3 <https://docs.python.org/3/using/index.html>`__.
- `Jupyter <http://jupyter.readthedocs.io/en/latest/install.html>`__
client is needed to run the tutorials, not to use as a library.
- Mac OS X users will find Xcode useful:
https://developer.apple.com/xcode/
- For Windows users we highly recommend to install `Anaconda 3 <https://www.continuum.io/downloads#windows>`_
- Optionally download Git: https://git-scm.com/download/.
2. Get the code
~~~~~~~~~~~~~~~
Clone the QISKit SDK repository and navigate to its folder on your local
machine:
- If you have Git installed, run the following commands:
.. code:: sh
git clone https://github.com/QISKit/qiskit-sdk-py
cd qiskit-sdk-py
- If you don't have Git installed, click the "Clone or download" button
at the URL shown in the git clone command, unzip the file if needed,
then navigate to that folder in a terminal window.
3. Setup the environment
~~~~~~~~~~~~~~~~~~~~~~~~
To use as a library install the dependencies:
.. code:: sh
# Depending on the system and setup to append "sudo -H" before could be needed.
pip3 install -r requires.txt
To get the tutorials working set up an Anaconda environment for working
with QISKit, and install the required dependencies:
- If running either Linux or Mac OS X with Xcode, simply run the
following command:
.. code:: sh
make env
- If running on Mac OS X without Xcode, run the following set of commands:
.. code:: sh
conda create -y -n QISKitenv python=3 pip scipy
activate QISKitenv
pip install -r requires.txt
- If running on Windows, make sure to execute an Anaconda Prompt and run
the following command:
.. code:: sh
.\make env
4. Configure your API token
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Create an `IBM Quantum
Experience <https://quantumexperience.ng.bluemix.net>`__ account if
you haven't already done so
- Get an API token from the Quantum Experience website under “My
Account” > “Personal Access Token”
- You will insert your API token in a file called Qconfig.py. First
copy the default version of this file from the tutorial folder to the
main SDK folder (on Windows, replace ``cp`` with ``copy``):
.. code:: sh
cp Qconfig.py.default Qconfig.py
- Open your Qconfig.py, remove the ``#`` from the beginning of the API
token line, and copy/paste your API token into the space between the
quotation marks on that line. Save and close the file.
Starting the Jupyter-based tutorials
------------------------------------
The SDK includes tutorials in the form of Jupyter notebooks, which are
essentially web pages that contain "cells" of embedded Python code. To
run a cell, click on it and hit ``Shift+Enter`` or use the toolbar at
the top of the page. Any output from a cell is displayed immediately
below it on the page. In most cases, the cells on each page must be run
in sequential order from top to bottom in order to avoid errors. To get
started with the tutorials, follow the instructions below.
- If running either Linux or Mac OS X with Xcode, simply run the
following command from the QISKit SDK folder:
.. code:: sh
make run
- If running on Mac OS X without Xcode, run the
following set of commands from the QISKit SDK folder:
.. code:: sh
activate QISKitenv
cd tutorial
jupyter notebook index.ipynb
- If running on Windows, make sure you are running an Anaconda Prompt,
and then run the following commands from the QISKit SDK folder:
.. code:: sh
.\make run
FAQ
---
If you upgrade the dependencies and get the error below, try the fix
shown below the error:
.. code:: sh
# Depending on the system and setup to append "sudo -H" before could be needed.
pip3 install --upgrade IBMQuantumExperience
*Cannot remove entries from nonexistent file [PATH]/easy-install.pth
# Fix: run the command below
curl https://bootstrap.pypa.io/ez_setup.py -o - | python
For additional troubleshooting tips, see the QISKit troubleshooting page
on the project's GitHub wiki.
Authors (alphabetical)
----------------------
Jim Challenger, Andrew Cross, Ismael Faro, Jay Gambetta, Juan Gomez, Paco Martin, Antonio Mezzacapo, Jesus Perez, and John Smolin, Erick Winston, Chris Wood.
In future releases, anyone who contributes code to this project can include their name here.
Other QISKit projects
---------------------
- `ibmqx backend information <https://github.com/QISKit/ibmqx-backend-information>`__ Information about the different IBM Q experience backends.
- `ibmqx user guide <https://github.com/QISKit/ibmqx-user-guides>`__ The users guides for the IBM Q experience.
- `OpenQasm <https://github.com/QISKit/openqasm>`__ Examples and tools for the OpenQASM intermediate representation.
- `Python API <https://github.com/QISKit/qiskit-api-py>`__ API Client to use IBM Q experience in Python.
- `Tutorials <https://github.com/QISKit/qiskit-tutorial>`__ Jupyter notebooks for using QISKit.
License
-------
QISKit is released under the `Apache license, version
2.0 <https://www.apache.org/licenses/LICENSE-2.0>`__.
Do you want to help?
--------------------
If you'd like to contribute please take a look to our
`contribution guidelines <CONTRIBUTING.rst>`__.
.. |Build Status| image:: https://travis-ci.org/QISKit/qiskit-sdk-py.svg?branch=master
:target: https://travis-ci.org/QISKit/qiskit-sdk-py

View File

@ -76,7 +76,7 @@ author = ''
# The short X.Y version.
version = ''
# The full version, including alpha/beta/rc tags.
release = '2.0'
release = '0.3.5'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@ -102,9 +102,14 @@ todo_include_todos = False
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# html_theme = 'alabaster'
# html_theme = 'bizstyle'
#html_theme = agogo
html_theme = 'theme' # use the theme in subdir 'theme'
html_theme_path = ['./'] # make sphinx search for themes in current dir
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
@ -118,7 +123,7 @@ html_static_path = ['_static']
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = '../images/QISKit-c.gif'
html_logo = '../images/qiskit-logo.gif'
# -- Options for HTMLHelp output ------------------------------------------

View File

@ -1 +0,0 @@
.. include:: ../CONTRIBUTING.rst

View File

@ -0,0 +1,39 @@
Example Real Chip Backend
=========================
.. code:: python
from qiskit import QuantumProgram
# Creating Programs create your first QuantumProgram object instance.
Q_program = QuantumProgram()
# Set your API Token
# You can get it from https://quantumexperience.ng.bluemix.net/qx/account, looking for "Personal Access Token" section.
QX_TOKEN = "API_TOKEN"
QX_URL = "https://quantumexperience.ng.bluemix.net/api"
# Set up the API and execute the program.
# You need the API Token and the QX URL.
Q_program.set_api(QX_TOKEN, QX_URL)
# Creating Registers create your first Quantum Register called "qr" with 2 qubits
qr = Q_program.create_quantum_register("qr", 2)
# create your first Classical Register called "cr" with 2 bits
cr = Q_program.create_classical_register("cr", 2)
# Creating Circuits create your first Quantum Circuit called "qc" involving your Quantum Register "qr" # and your Classical Register "cr"
qc = Q_program.create_circuit("superposition", [qr], [cr])
# add the H gate in the Qubit 0, we put this Qubit in superposition
qc.h(qr[0])
# add measure to see the state
qc.measure(qr, cr)
# Compiled and execute in the local_qasm_simulator
result = Q_program.execute(["superposition"], backend='ibmqx2', shots=1024)
# Show the results
print(result)
print(result.get_data("superposition"))

View File

@ -3,79 +3,29 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
======
QISKit
======
Quantum Information Software Kit
.. include:: qiskit.rst
Project Overview
================
The QISKit project comprises:
Python Modules
==============
Main Modules
------------
* `QISKit API <https://github.com/IBM/qiskit-api-py>`_: A thin Python
wrapper around the Quantum Experience HTTP API that enables you to
connect and and execute OpenQASM code.
* `QISKit SDK <https://github.com/IBM/qiskit-sdk-py>`_: Provides
support for the Quantum Experience circuit generation phase and lets
you use the QISKit API to access the Quantum Experience hardware and
simulators. The SDK also includes example scripts written for
Jupyter Notebooks.
* `QISKit OpenQASM <https://github.com/IBM/qiskit-openqasm>`_: Contains
specifications, examples, documentation, and tools for the OpenQASM
intermediate representation.
Getting Started
===============
The starting point for writing code is the QuantumProgram object. The
QuantumProgram is a collection of circuits, or scores if you are
coming from the Quantum Experience, quantum register objects, and
classical register objects. The QuantumProgram methods can send these
circuits to quantum hardware or simulator backends and collect the
results for further analysis.
To compose and run a circuit on a simulator, which is distributed with
this project, one can do,
.. code-block:: python
from qiskit import QuantumProgram
qp = QuantumProgram()
qr = qp.create_quantum_register('qr', 2)
cr = qp.create_classical_register('cr', 2)
qc = qp.create_circuit('Bell', [qr], [cr])
qc.h(qr[0])
qc.cx(qr[0], qr[1])
qc.measure(qr[0], cr[0])
qc.measure(qr[1], cr[1])
result = qp.execute('Bell')
result.get_counts('Bell')
The :code:`get_counts` method outputs a dictionary of state:counts pairs;
.. code-block:: python
{'00': 531, '11': 493}
.. testoutput::
:hide:
:options: -ELLIPSIS, +NORMALIZE_WHITESPACE
* `Quantum Program <./_autodoc/qiskit._quantumprogram.html>`__
* `Quantum Circuit <./_autodoc/qiskit._quantumcircuit.html>`__
* :ref:`modindex`
.. toctree::
:maxdepth: 2
:maxdepth: 4
:caption: Contents:
contributing
_autodoc/modules
Indices and tables
==================
.. include:: install.rst
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Authors (alphabetical)
======================
Jim Challenger, Andrew Cross, Ismael Faro, Jay Gambetta, Juan Gomez, Paco Martin, Antonio Mezzacapo, Jesus Perez, and John Smolin, Erick Winston, Chris Wood.
In future releases, anyone who contributes code to this project can include their name here.

165
doc/install.rst Normal file
View File

@ -0,0 +1,165 @@
Installation and setup
======================
1. Get the tools
----------------
To use QISKit you'll need to have installed at least `Python 3.5 or
later <https://www.python.org/downloads/`__ and `Jupyter Notebooks
<https://jupyter.readthedocs.io/en/latest/install.html>`__
(recommended for interacting with the tutorials).
For this reason we recommend installing `Anaconda 3 <https://www.continuum.io/downloads>`__
python distribution, which already comes with all these dependencies pre-installed.
if you are a Mac OS X user, you will find Xcode useful: https://developer.apple.com/xcode/
if you are willing to contribute to QISKit or just wanted to extend it, you should install Git too: https://git-scm.com/download/.
2. PIP Install
--------------
The fastest way to install QISKit is by using the PIP tool (Python package manager):
.. code:: sh
pip install qiskit
3 Repository Install
---------------------
Other common option is to clone the QISKit SDK repository on your local machine, and change into the cloned directory:
- If you have Git installed, run the following commands:
.. code:: sh
git clone https://github.com/QISKit/qiskit-sdk-py
cd qiskit-sdk-py
- If you don't have Git installed, click the "Clone or download"
button on the `QISKit SDK GitHub repo <https://github.com/QISKit/qiskit-sdk-py>`__, unzip the file if
needed and finally change into the unziped directory.
3.1 Setup the environment
-------------------------
To use QISKit as standalone library, install all the dependencies:
.. code:: sh
# Depending on the system and setup, appending "sudo -H" before this command could be needed.
pip install -r requires.txt
To get the tutorials working set up an Anaconda environment for working
with QISKit, and install the required dependencies:
- If running either Linux or Mac OS X with Xcode, simply run the
following command:
.. code:: sh
make env
- If running on Mac OS X without Xcode, run the following set of commands:
.. code:: sh
conda create -y -n QISKitenv python=3 pip scipy
activate QISKitenv
pip install -r requires.txt
- If running on Windows, make sure to execute an Anaconda Prompt and run
the following command:
.. code:: sh
.\make env
4. Configure your API token
---------------------------
- Create an `IBM Q
experience <https://quantumexperience.ng.bluemix.net>`__ account if
you haven't already done so
- Get an API token from the IBM Q experience website under “My
Account” > “Personal Access Token”
- You will insert your API token in a file called Qconfig.py. First
copy the default version of this file from the tutorial folder to the
main SDK folder (on Windows, replace ``cp`` with ``copy``):
.. code:: sh
cp Qconfig.py.default Qconfig.py
- Open your Qconfig.py, remove the ``#`` from the beginning of the API
token line, and copy/paste your API token into the space between the
quotation marks on that line. Save and close the file.
Install Jupyter-based tutorials
===============================
The QISKit project provides you a collection of tutorials in the form of Jupyter
notebooks, which are essentially web pages that contain "cells" of embedded
Python code. To run a cell, click on it and hit ``Shift+Enter`` or use the
toolbar at the top of the page. Any output from a cell is displayed
immediately below it on the page. In most cases, the cells on each page must
be run in sequential order from top to bottom in order to avoid errors. To get
started with the tutorials, follow the instructions below.
1.1 Install standalone
----------------------
- download the tutorials: https://github.com/QISKit/qiskit-tutorial/archive/master.zip
- uncompress the zip file
- in the terminal/command-line and into the folder "qiskit-tutorial-master" execute:
.. code:: sh
jupyter notebook index.ipynb
1.2 Install into the QISKit folder
----------------------------------
- If running either Linux or Mac OS X with Xcode, simply run the
following command from the QISKit SDK folder:
.. code:: sh
make install-tutorials
make run-tutorials
- If running on Windows, make sure you are running an Anaconda Prompt,
and then run the following commands from the QISKit SDK folder:
- download the tutorials: https://github.com/QISKit/qiskit-tutorial/archive/master.zip
- uncompress the zip file
- move the content into a new "tutorials" folder in the QISKit folder
.. code:: sh
.\make run-tutorials
FAQ
===
If you upgrade the dependencies and get the error below, try the fix
shown below the error:
- Depending on the system and setup, appending "sudo -H" before this command could be needed.
.. code:: sh
pip install -U --no-cache-dir IBMQuantumExperience
- Fix: run the command below
.. code:: sh
curl https://bootstrap.pypa.io/ez_setup.py -o - | python
For additional troubleshooting tips, see the QISKit troubleshooting page
on the project's GitHub wiki

145
doc/qiskit.rst Normal file
View File

@ -0,0 +1,145 @@
====================
QISKit Documentation
====================
Quantum Information Software Kit (QISKit), SDK Python version for working
with `OpenQASM <https://github.com/QISKit/openqasm>`_ and the IBM Q experience (QX).
Philosophy
==========
QISKit is a collection of software for working with short depth
quantum circuits and building near term applications and experiments
on quantum computers. In QISKit, a quantum program is an array of
quantum circuits. The program workflow consists of three stages:
Build, Compile, and Run. Build allows you to make different quantum
circuits that represent the problem you are solving. Compile allows
you to rewrite them to run on different backends (simulators/real
chips of different quantum volumes, sizes, fidelity, etc). Run
launches the jobs. After the jobs have been run, the data is
collected. There are methods for putting this data together, depending
on the program. This either gives you the answer you wanted or allows
you to make a better program for the next instance.
Project Overview
================
The QISKit project comprises:
* `QISKit SDK <https://github.com/IBM/qiskit-sdk-py>`_: Provides
support for the Quantum Experience circuit generation phase and lets
you use the QISKit API to access the Quantum Experience hardware and
simulators. The SDK also includes example scripts written for
Jupyter Notebooks.
* `QISKit API <https://github.com/IBM/qiskit-api-py>`_: A thin Python
wrapper around the Quantum Experience HTTP API that enables you to
connect and and execute OpenQASM code.
* `QISKit OpenQASM <https://github.com/IBM/qiskit-openqasm>`_: Contains
specifications, examples, documentation, and tools for the OpenQASM
intermediate representation.
Getting Started
===============
The starting point for writing code is the QuantumProgram object. The
QuantumProgram is a collection of circuits, or scores if you are
coming from the Quantum Experience, quantum register objects, and
classical register objects. The QuantumProgram methods can send these
circuits to quantum hardware or simulator backends and collect the
results for further analysis.
To compose and run a circuit on a simulator, which is distributed with
this project, one can do,
.. code-block:: python
from qiskit import QuantumProgram
qp = QuantumProgram()
qr = qp.create_quantum_register('qr', 2)
cr = qp.create_classical_register('cr', 2)
qc = qp.create_circuit('Bell', [qr], [cr])
qc.h(qr[0])
qc.cx(qr[0], qr[1])
qc.measure(qr[0], cr[0])
qc.measure(qr[1], cr[1])
result = qp.execute('Bell')
print(result.get_counts('Bell'))
The :code:`get_counts` method outputs a dictionary of state:counts pairs;
.. code-block:: python
{'00': 531, '11': 493}
Quantum Chips
-------------
You can execute your QASM circuits on a real chip by using the IBM Quantum Experience (QX) cloud platform. Currently through QX you can use the following chips:
- ibmqx2: `5-qubit backend <https://ibm.biz/qiskit-ibmqx2>`_
- ibmqx3: `16-qubit backend <https://ibm.biz/qiskit-ibmqx3>`_
For chip details visit the `IBM Q experience backend information <https://github.com/QISKit/ibmqx-backend-information>`_
`Example code <example_real_backend.html>`__
Project Organization
--------------------
Python example programs can be found in the *examples* directory, and test scripts are
located in *test*. The *qiskit* directory is the main module of the SDK.
Structure
=========
Programming interface
---------------------
The *qiskit* directory is the main Python module and contains the
programming interface objects :py:mod:`QuantumProgram <qiskit._quantumprogram>`, :py:mod:`QuantumRegister <qiskit._quantumregister>`, :py:mod:`ClassicalRegister <qiskit._classicalregister>`, and :py:mod:`QuantumCircuit <qiskit._quantumcircuit>`.
At the highest level, users construct a *QuantumProgram* to create,
modify, compile, and execute a collection of quantum circuits. Each
*QuantumCircuit* has a set of data registers, each of type
*QuantumRegister* or *ClassicalRegister*. Methods of these objects are
used to apply instructions that define the circuit. The *QuantumCircuit*
can then generate **OpenQASM** code that can flow through other
components in the *qiskit* directory.
The *extensions* directory extends quantum circuits as needed to support
other gate sets and algorithms. Currently there is a *standard*
extension defining some typical quantum gates.
Internal modules
----------------
The directory also contains internal modules that are still under development:
- a *qasm* module for parsing **OpenQASM** circuits
- an *unroll* module to interpret and “unroll” **OpenQASM** to a target gate basis (expanding gate subroutines and loops as needed)
- a *dagcircuit* module for working with circuits as graphs
- a *mapper* module for mapping all-to-all circuits to run on devices with fixed couplings
- a *simulators* module contains quantum circuit simulators
- a *tools* directory contains methods for applications, analysis, and visualization
Quantum circuits flow through the components as follows. The programming interface is used to generate **OpenQASM** circuits, as text or *QuantumCircuit* objects. **OpenQASM** source, as a file or string, is passed into a *Qasm* object, whose parse method produces an abstract syntax tree (**AST**). The **AST** is passed to an *Unroller* that is attached to an *UnrollerBackend*. There is a *PrinterBackend* for outputting text, a *JsonBackend* for producing input to simulator and experiment backends, a *DAGBackend* for constructing *DAGCircuit* objects, and a *CircuitBackend* for producing *QuantumCircuit* objects. The *DAGCircuit* object represents an “unrolled” **OpenQASM** circuit as a directed acyclic graph (DAG). The *DAGCircuit* provides methods for representing, transforming, and computing properties of a circuit and outputting the results again as **OpenQASM**. The whole flow is used by the *mapper* module to rewrite a circuit to execute on a device with fixed couplings given by a *CouplingGraph*. The structure of these components is subject to change.
The circuit representations and how they are currently transformed into each other are summarized in this figure:
.. image:: ../images/circuit_representations.png
:width: 600px
:align: center
Several unroller backends and their outputs are summarized here:
.. image:: ../images/unroller_backends.png
:width: 600px
:align: center

BIN
doc/theme.textClipping Normal file

Binary file not shown.

32
doc/theme/layout.html vendored Normal file
View File

@ -0,0 +1,32 @@
{#
bizstyle/layout.html
~~~~~~~~~~~~~~~~~~~~
Sphinx layout template for the bizstyle theme.
:copyright: Copyright 2011 by Sphinx-users.jp, see AUTHORS.
:license: MIT, see LICENSE for details.
#}
{% extends "basic/layout.html" %}
{% set script_files = script_files + ["_static/bizstyle.js"] %}
{# put the sidebar before the body #}
{% block sidebar1 %}{{ sidebar() }}{% endblock %}
{% block sidebar2 %}{% endblock %}
{# doctype override #}
{%- block doctype %}
<!doctype html>
{%- endblock %}
{%- block extrahead %}
<div id="head" class="head">
<a href="../"> QISKit </a>
</div>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!--[if lt IE 9]>
<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
<![endif]-->
{%- endblock %}

BIN
doc/theme/static/background_b01.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 B

BIN
doc/theme/static/background_r12.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 B

502
doc/theme/static/bizstyle.css_t vendored Normal file
View File

@ -0,0 +1,502 @@
/*
* bizstyle.css_t
* ~~~~~~~~~~~~~~
*
* Sphinx stylesheet -- business style theme.
*
* :copyright: Copyright 2011 by Sphinx-users.jp, see AUTHORS.
* :license: MIT, see LICENSE for details.
*
*/
@import url("basic.css");
div.head {
height:30px;
background-color:#000;
text-align: left;
text-decoration:none;
cursor:pointer;
padding: 8px 0px 0px 8px;
}
div.head a {
color: #FFF!important;
text-decoration:none;
cursor:pointer;
}
/* -- page layout ----------------------------------------------------------- */
body {
font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva',
'Verdana', sans-serif;
font-size: 14px;
letter-spacing: -0.01em;
line-height: 150%;
text-align: center;
background-color: white;
color: black;
padding: 0;
#border-right: 1px solid {{ theme_maincolor }};
#border-left: 1px solid {{ theme_maincolor }};
margin: 0px 0px 0px 0px;
}
div.document {
background-color: white;
text-align: left;
background-repeat: repeat-x;
}
div.bodywrapper {
margin: 0 0 0 240px;
#border-left: 1px solid #ccc;
}
div.body {
margin: 0;
padding: 0.5em 20px 20px 20px;
}
{%- if theme_rightsidebar|tobool %}
div.bodywrapper {
margin: 0 240px 0 0;
#border-right: 1px solid #ccc;
}
{%- endif %}
div.related {
font-size: 1em;
}
div.related ul {
background-color: {{ theme_maincolor }};
height: 2em;
border-bottom: 1px solid #ddd;
}
div.related ul li {
color: white;
margin: 0;
padding: 0;
height: 2em;
float: left;
}
div.related ul li.right {
float: right;
margin-right: 5px;
}
div.related ul li a {
margin: 0;
padding: 0 5px 0 5px;
line-height: 1.75em;
color: #fff;
}
div.related ul li a:hover {
color: #fff;
text-decoration: underline;
}
div.sphinxsidebarwrapper {
padding: 0;
}
div.sphinxsidebar {
margin: 0;
padding: 0.5em 12px 12px 12px;
width: 210px;
{%- if theme_rightsidebar|tobool %}
float: right;
{%- endif %}
font-size: 1em;
text-align: left;
}
div.sphinxsidebar h3, div.sphinxsidebar h4 {
margin: 1em 0 0.5em 0;
font-size: 1em;
padding: 0.1em 0 0.1em 0.5em;
color: white;
border: 1px solid {{ theme_maincolor }};
background-color: {{ theme_maincolor }};
}
div.sphinxsidebar h3 a {
color: white;
}
div.sphinxsidebar ul {
padding-left: 1.5em;
margin-top: 7px;
padding: 0;
line-height: 130%;
}
div.sphinxsidebar ul ul {
margin-left: 20px;
}
div.sphinxsidebar input {
border: 1px solid {{ theme_maincolor }};
width: 100%!important;
height: 24px;
margin-bottom: 6px;
}
div.footer {
background-color: white;
color: {{ theme_maincolor }};
padding: 3px 8px 3px 0;
clear: both;
font-size: 0.8em;
text-align: right;
border-bottom: 1px solid {{ theme_maincolor }};
}
div.footer a {
color: {{ theme_maincolor }};
text-decoration: underline;
}
/* -- body styles ----------------------------------------------------------- */
p {
margin: 0.8em 0 0.5em 0;
}
a {
color: {{ theme_maincolor }};
text-decoration: none;
}
a:hover {
color: {{ theme_maincolor }};
text-decoration: underline;
}
div.body a {
text-decoration: underline;
}
h1, h2, h3 {
color: {{ theme_maincolor }};
}
h1 {
margin: 0;
padding: 0.7em 0 0.3em 0;
font-size: 1.5em;
}
h2 {
margin: 1.3em 0 0.2em 0;
font-size: 1.35em;
padding-bottom: .5em;
border-bottom: 1px solid {{ theme_maincolor }};
}
h3 {
margin: 1em 0 -0.3em 0;
font-size: 1.2em;
padding-bottom: .3em;
border-bottom: 1px solid #CCCCCC;
}
div.body h1 a, div.body h2 a, div.body h3 a,
div.body h4 a, div.body h5 a, div.body h6 a {
color: black!important;
}
h1 a.anchor, h2 a.anchor, h3 a.anchor,
h4 a.anchor, h5 a.anchor, h6 a.anchor {
display: none;
margin: 0 0 0 0.3em;
padding: 0 0.2em 0 0.2em;
color: #aaa!important;
}
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor,
h5:hover a.anchor, h6:hover a.anchor {
display: inline;
}
h1 a.anchor:hover, h2 a.anchor:hover, h3 a.anchor:hover, h4 a.anchor:hover,
h5 a.anchor:hover, h6 a.anchor:hover {
color: #777;
background-color: #eee;
}
a.headerlink {
color: #c60f0f!important;
font-size: 1em;
margin-left: 6px;
padding: 0 4px 0 4px;
text-decoration: none!important;
}
a.headerlink:hover {
background-color: #ccc;
color: white!important;
}
cite, code, tt {
font-family: 'Consolas', 'Deja Vu Sans Mono',
'Bitstream Vera Sans Mono', monospace;
font-size: 0.95em;
letter-spacing: 0.01em;
}
tt {
background-color: #F2F2F2;
border-bottom: 1px solid #ddd;
color: #333;
}
tt.descname, tt.descclassname, tt.xref {
border: 0;
}
hr {
border: 1px solid #abc;
margin: 2em;
}
a tt {
border: 0;
color: #CA7900;
}
a tt:hover {
color: #2491CF;
}
pre {
font-family: 'Consolas', 'Deja Vu Sans Mono',
'Bitstream Vera Sans Mono', monospace;
font-size: 0.95em;
letter-spacing: 0.015em;
line-height: 120%;
padding: 0.5em;
border-right: 5px solid #ccc;
border-left: 5px solid #ccc;
}
pre a {
color: inherit;
text-decoration: underline;
}
td.linenos pre {
padding: 0.5em 0;
}
div.quotebar {
background-color: #f8f8f8;
max-width: 250px;
float: right;
padding: 2px 7px;
border: 1px solid #ccc;
}
div.topic {
background-color: #f8f8f8;
}
table {
border-collapse: collapse;
margin: 0 -0.5em 0 -0.5em;
}
table td, table th {
padding: 0.2em 0.5em 0.2em 0.5em;
}
div.admonition {
font-size: 0.9em;
margin: 1em 0 1em 0;
border: 3px solid #cccccc;
background-color: #f7f7f7;
padding: 0;
}
div.admonition p {
margin: 0.5em 1em 0.5em 1em;
padding: 0;
}
div.admonition li p {
margin-left: 0;
}
div.admonition pre, div.warning pre {
margin: 0.4em 1em 0.4em 1em;
}
div.admonition p.admonition-title {
margin: 0;
padding: 0.1em 0 0.1em 0.5em;
color: white;
border-bottom: 3px solid #cccccc;
font-weight: bold;
background-color: #165e83;
}
div.danger { border: 3px solid #f0908d; background-color: #f0cfa0; }
div.error { border: 3px solid #f0908d; background-color: #ede4cd; }
div.warning { border: 3px solid #f8b862; background-color: #f0cfa0; }
div.caution { border: 3px solid #f8b862; background-color: #ede4cd; }
div.attention { border: 3px solid #f8b862; background-color: #f3f3f3; }
div.important { border: 3px solid #f0cfa0; background-color: #ede4cd; }
div.note { border: 3px solid #f0cfa0; background-color: #f3f3f3; }
div.hint { border: 3px solid #bed2c3; background-color: #f3f3f3; }
div.tip { border: 3px solid #bed2c3; background-color: #f3f3f3; }
div.danger p.admonition-title, div.error p.admonition-title {
background-color: #b7282e;
border-bottom: 3px solid #f0908d;
}
div.caution p.admonition-title,
div.warning p.admonition-title,
div.attention p.admonition-title {
background-color: #f19072;
border-bottom: 3px solid #f8b862;
}
div.note p.admonition-title, div.important p.admonition-title {
background-color: #f8b862;
border-bottom: 3px solid #f0cfa0;
}
div.hint p.admonition-title, div.tip p.admonition-title {
background-color: #7ebea5;
border-bottom: 3px solid #bed2c3;
}
div.admonition ul, div.admonition ol,
div.warning ul, div.warning ol {
margin: 0.1em 0.5em 0.5em 3em;
padding: 0;
}
div.versioninfo {
margin: 1em 0 0 0;
border: 1px solid #ccc;
background-color: #DDEAF0;
padding: 8px;
line-height: 1.3em;
font-size: 0.9em;
}
.viewcode-back {
font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva',
'Verdana', sans-serif;
}
div.viewcode-block:target {
background-color: #f4debf;
border-top: 1px solid #ac9;
border-bottom: 1px solid #ac9;
}
p.versionchanged span.versionmodified {
font-size: 0.9em;
margin-right: 0.2em;
padding: 0.1em;
background-color: #DCE6A0;
}
/* -- table styles ---------------------------------------------------------- */
table.docutils {
margin: 1em 0;
padding: 0;
border: 1px solid white;
background-color: #f7f7f7;
}
table.docutils td, table.docutils th {
padding: 1px 8px 1px 5px;
border-top: 0;
border-left: 0;
border-right: 1px solid white;
border-bottom: 1px solid white;
}
table.docutils td p {
margin-top: 0;
margin-bottom: 0.3em;
}
table.field-list td, table.field-list th {
border: 0 !important;
word-break: break-word;
}
table.footnote td, table.footnote th {
border: 0 !important;
}
th {
color: white;
text-align: left;
padding-right: 5px;
background-color: #82A0BE;
}
/* WIDE DESKTOP STYLE */
@media only screen and (min-width: 1176px) {
body {
margin: 0 0px 0 0px;
}
}
/* TABLET STYLE */
@media only screen and (min-width: 768px) and (max-width: 991px) {
body {
margin: 0 0px 0 0px;
}
}
/* MOBILE LAYOUT (PORTRAIT/320px) */
@media only screen and (max-width: 767px) {
body {
margin: 0;
}
div.bodywrapper {
margin: 0;
width: 100%;
border: none;
}
div.sphinxsidebar {
display: none;
}
}
/* MOBILE LAYOUT (LANDSCAPE/480px) */
@media only screen and (min-width: 480px) and (max-width: 767px) {
body {
margin: 0 20px 0 20px;
}
}
/* RETINA OVERRIDES */
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min-device-pixel-ratio: 2) {
}
/* -- end ------------------------------------------------------------------- */

45
doc/theme/static/bizstyle.js_t vendored Normal file
View File

@ -0,0 +1,45 @@
//
// bizstyle.js
// ~~~~~~~~~~~
//
// Sphinx javascript -- for bizstyle theme.
//
// This theme was created by referring to 'sphinxdoc'
//
// :copyright: Copyright 2012 by Sphinx-users.jp, see AUTHORS.
// :license: MIT, see LICENSE for details.
//
$(document).ready(function(){
if (navigator.userAgent.indexOf('iPhone') > 0 ||
navigator.userAgent.indexOf('Android') > 0) {
$("div.related ul li:not(.right) a").text("Top");
}
$("div.related:first ul li:not(.right) a").slice(1).each(function(i, item){
if (item.text.length > 20) {
var tmpstr = item.text
$(item).attr("title", tmpstr);
$(item).text(tmpstr.substr(0, 5) + "...");
alert(i + ":" + item.text + ":" + $(item).attr("title") + ":" + $(item).size());
}
});
$("div.related:last ul li:not(.right) a").slice(1).each(function(i, item){
if (item.text.length > 20) {
var tmpstr = item.text
$(item).attr("title", tmpstr);
$(item).text(tmpstr.substr(0, 5) + "...");
alert(i + ":" + item.text + ":" + $(item).attr("title") + ":" + $(item).size());
}
});
});
$(window).resize(function(){
if ($(window).width() <= 776) {
$("div.related:first ul li:not(.right):first a").text("Top");
$("div.related:last ul li:not(.right):first a").text("Top");
}
else {
$("div.related:first ul li:not(.right):first a").text("{{ shorttitle|e }}");
$("div.related:last ul li:not(.right):first a").text("{{ shorttitle|e }}");
}
});

9
doc/theme/theme.conf vendored Normal file
View File

@ -0,0 +1,9 @@
[theme]
inherit = basic
stylesheet = bizstyle.css
pygments_style = friendly
[options]
rightsidebar = false
maincolor = #336699

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 71 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 77 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 34 KiB