Go to file
Andrew Cross 7953920336 Consolidate QASM examples into the testscripts directory and organize them. 2017-05-04 12:47:10 -04:00
qiskit Consolidate QASM examples into the testscripts directory and organize them. 2017-05-04 12:47:10 -04:00
scripts improve QuantumProgram and added Tests 2017-05-04 03:16:40 -04:00
testscripts Consolidate QASM examples into the testscripts directory and organize them. 2017-05-04 12:47:10 -04:00
tools Update with the last Jay modifications 2017-05-03 14:41:29 -04:00
.gitignore Add external token 2017-05-03 02:00:32 -04:00
QISKit-tests.py add File Headers 2017-05-04 03:49:22 -04:00
README.md improve QuantumProgram and added Tests 2017-05-04 03:16:40 -04:00
config.json add config.json file 2017-05-02 19:56:45 -04:00
index.ipynb cleaning up optimization 2017-04-20 23:07:20 -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
rippleadd.py change coupling constructor, make single import statement, change a lexer error message 2017-04-26 17:21:53 -04:00
teleport.py fix variable names and add required modules 2017-05-03 16:11:54 -04:00
teleport_obj.py add 2 dev examples 2017-05-02 19:55:38 -04:00

README.md

Python SDK

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.

Setup Python Virtual Enviroment

Anaconda

To create a new Virtual Enviroment:

conda create -n QISKitenv python=3 pip

use it:

source activate QISKitenv

Install Dependencies

pip install -r requires.txt

use the Jupyter Notebook

cd script

mv Qconfig.py.default Qconfig.py

edit the Qconfig.py and add your APItoken, you can get it from IBM Quantum Experience > Account

jupyter notebook

Dependencies problems.

When you try to install the dependencies "pip install --upgrade IBMQuantumExperience", if you have the next error:

  • Cannot remove entries from nonexistent file [PATH]/easy-install.pth

You can fix it using:

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