Go to file
ismael faro 1de76156dd Merge branch 'isma/clean-quantum-program' into Dev 2017-05-12 23:05:16 -04:00
examples update examples. 2017-05-12 09:46:46 -04:00
images Added images directory with some diagrams. 2017-05-12 14:30:16 -04:00
qiskit Clean: tutorial > remove the helper dependencies 2017-05-12 23:04:36 -04:00
test fix variable names in run&execution 2017-05-12 22:29:23 -04:00
tools Support for core libraries, ie: qelib1.inc 2017-05-11 20:37:52 +02:00
tutorial Clean: tutorial > remove the helper dependencies 2017-05-12 23:04:36 -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 Travis token updated. 2017-05-12 08:51:34 +02: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 scripts directory contains Jupyter notebooks showing how to use the Python API with OPENQASM.

There are Jupyter notebooks demonstrating components of the SDK in the scripts directory. There are also command line test scripts in the testscripts directory. The root directory contains some miscellaneous examples and an index Jupyter notebook.

We want to reorganize the SDK so that it has a comfortable and intuitive interface for developers.

Users can create instances of QuantumRegister and ClassicalRegister, and use these to construct a QuantumCircuit. They can then call methods of these objects to apply gates within the circuit. The extensions directory extends these objects as needed to support new gate sets and algorithms. 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 QuantumRegister, ClassicalRegister, and QuantumCircuit. The directory also contains 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 localize 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) representation. 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 localize module's swap_mapper method to insert SWAP gates so a circuit can execute on a device with fixed couplings given by a CouplingGraph.

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 with 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 the 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.