Go to file
ismael faro 73aed08c81 ADD: Rippleadd Example
fix create circuit arguments
2017-05-08 00:50:44 -04:00
qiskit ADD: Rippleadd Example 2017-05-08 00:50:44 -04:00
scripts improve QuantumProgram and added Tests 2017-05-04 03:16:40 -04:00
testscripts Update test programs. 2017-05-04 12:50:37 -04:00
tools Update with the last Jay modifications 2017-05-03 14:41:29 -04:00
.gitignore TODOs for awc; update gitignore for vscode files 2017-05-04 16:38:38 -04:00
QISKit-tests.py Improve: Quantum Program 2017-05-08 00:27:15 -04:00
README.md Anaconda added to the requisites and some minor linting. 2017-05-05 16:25:26 +02: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 TODOs for awc; update gitignore for vscode files 2017-05-04 16:38:38 -04:00
rippleadd_obj.py ADD: Rippleadd Example 2017-05-08 00:50:44 -04:00
teleport.py fix variable names and add required modules 2017-05-03 16:11:54 -04:00
teleport_obj.py ADD: Rippleadd Example 2017-05-08 00:50:44 -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.

Install

git clone https://github.ibm.com/IBMQuantum/qiskit-sdk-py-dev
cd qiskit-sdk-py-dev
  • Virtual environment:
# Creation
conda create -n QISKitenv python=3 pip
# Setup
source activate QISKitenv
  • Install project dependencies:
pip install -r requires.txt
  • Setup the Jupyter notebook. Add your API token to the file "Qconfig.py" (get it from IBM Quantum Experience > Account):
cd script
mv Qconfig.py.default Qconfig.py
  • Run it:
jupyter notebook

Dependencies problem

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