Go to file
ismael faro 5db9593449 review variable names: _quantumprogram.py
coupling_map instead of layout
2017-05-10 17:48:35 -04:00
examples/Python fix cx cancellation assumption; move methods to _mapping.py 2017-05-10 11:14:03 -04:00
qiskit review variable names: _quantumprogram.py 2017-05-10 17:48:35 -04:00
scripts Merge remote-tracking branch 'origin/jay-branch-temp' into Dev 2017-05-09 02:32:54 -04:00
test review variable names: _quantumprogram.py 2017-05-10 17:48:35 -04:00
tools compiled output proposal 2017-05-09 09:27:41 -04:00
tutorial Merge remote-tracking branch 'origin/jay-branch-temp' into Dev 2017-05-09 02:32:54 -04:00
.gitignore Tests get the QE key from an env variable now. 2017-05-10 19:27:27 +02:00
.rclint Review&Fix: Tests, Make, rclint file 2017-05-08 13:01:24 -04:00
.travis.yml Tests only works in Python 3, so dropping the old versions there. 2017-05-10 19:33:56 +02:00
Makefile Fix in the Makefile to get Anaconda working properly. 2017-05-10 19:17:56 +02:00
README.md Add Load in _quantumprogram.py and Fix some issues 2017-05-10 17:41:28 -04:00
qelib1.inc Update with the last Jay modifications 2017-05-03 14:41:29 -04:00
requires.txt fix variable names and add required modules 2017-05-03 16:11:54 -04:00

README.md

Build Status

Qiskit SDK Python

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:
export QE_TOKEN=putYourQExperienceTokenHere
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.