Go to file
Andrew Cross b85f8a8e32 Move examples to jupyter directory. 2017-05-15 15:06:24 -04:00
examples Move examples to jupyter directory. 2017-05-15 15:06:24 -04:00
images update README and unroller_backends images. 2017-05-14 23:12:44 -04:00
qiskit adding result.data to the simulators 2017-05-15 14:06:25 -04:00
test adding result.data to the simulators 2017-05-15 14:06:25 -04:00
tools Support for core libraries, ie: qelib1.inc 2017-05-11 20:37:52 +02:00
tutorial Move examples to jupyter directory. 2017-05-15 15:06:24 -04:00
.gitignore Qconfig file in tests not needed anymore. 2017-05-11 18:12:45 +02:00
.pylintrc Default lint file to start. 2017-05-11 13:19:02 +02:00
.travis.yml Minor licensing changes. 2017-05-11 18:12:57 +02:00
Makefile Important TODO about the linting in the workflow. 2017-05-11 19:50:07 +02:00
README.md resize images again. 2017-05-15 10:01:25 -04:00
requires.txt Merge remote-tracking branch 'origin/Dev' into Dev 2017-05-11 02:03:49 -04:00

README.md

Qiskit SDK Python

Build Status

Python software development kit (SDK) and Jupyter notebooks for working with OPENQASM and the IBM Quantum Experience (QE).

Related external projects:

Organization

The tutorial directory contains Jupyter notebooks showing how to use the Python API with OPENQASM.

There are Jupyter notebooks demonstrating components of the SDK in the tutorial directory, and more python and qasm examples in the examples directory. There are also command line test scripts in the test directory.

Users can construct a QuantumProgram to create, modify, compile, and execute a collection of quantum circuits.

Each QuantumCircuit has some set of registers, QuantumRegister and ClassicalRegister, and methods of these objects are used to apply instructions within the circuit. The extensions directory extends the quantum circuit as needed to support new gate sets and algorithms. For example, the "cswap" gate in the standard extension shows how to build gates that are sequences of other unitary gates. The Python file "header.py" shows how we append OPENQASM gate definitions as we import extensions. The QuantumCircuit can generate OPENQASM code that can flow through other components in the qiskit directory.

The qiskit directory is the main Python module and contains the programming interface objects QuantumProgram, QuantumRegister, ClassicalRegister, and QuantumCircuit. The directory also contains internal modules: a qasm module for parsing OPENQASM circuits, an unroll module to "flatten" QASM for a target gate basis by expanding gate subroutines as needed, a circuit module for working with circuits as graphs, and 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 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 as a DAG 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 circuit representations and how they are currently transformed into each other are summarized here: circuits

The unroller backends and their outputs are summarized here: backends

Install

git clone https://github.ibm.com/IBMQuantum/qiskit-sdk-py-dev
cd qiskit-sdk-py-dev
  • Create the environment with the dependencies:
make env

Use

  • Setup the Jupyter notebook. Add your API token to the file "Qconfig.py" (get it from IBM Quantum Experience > Account):
cp tutorial/Qconfig.py.default Qconfig.py
  • Run it:
make run

FAQ

If you upgrade the dependencies and next error happens try this fix:

pip install --upgrade IBMQuantumExperience
* Cannot remove entries from nonexistent file [PATH]/easy-install.pth

# Fix
curl https://bootstrap.pypa.io/ez_setup.py -o - | python

Developer guide

Please, use GitHub pull requests to send contributions.

We use Pylint and PEP 8 style guide.

Dependencies

make env-dev

Test

  • Please run this to be sure your code fits with the style guide and the tests keep passing:
make test

Note: You can get yout "putYourQExperienceTokenHere" from IBM Quantum Experience > Account)

Commit messages rules

  • It should be formed by a one-line subject, followed by one line of white space. Followed by one or more descriptive paragraphs, each separated by one line of white space. All of them finished by a dot.
  • If it fixes an issue, it should include a reference to the issue ID in the first line of the commit.
  • It should provide enough information for a reviewer to understand the changes and their relation to the rest of the code.