Terra provides the foundations for Qiskit. It allows the user to write quantum circuits easily, and takes care of the constraints of real hardware.
Clone or download
delapuente Merge pull request #921 from delapuente/issue-920-fix-master-broken-d…
…ue-to-matplot-update

Pinning to matplotlib < 3 to avoid incompatibility issues.
Latest commit ba61fb2 Sep 20, 2018
Permalink
Failed to load latest commit information.
.github updating codeowners Sep 6, 2018
cmake 0.6 release notes (#867) Sep 11, 2018
doc 0.6 release notes (#867) Sep 11, 2018
examples Replace properties in jobs and backends with methods. Sep 4, 2018
images Update Sphinx theme color and diagrams Oct 17, 2017
qiskit Parallel tools and compiling (#701) Sep 18, 2018
src/qasm-simulator-cpp Retire Quantum Program (#724) Aug 27, 2018
test New cassettes (#912) Sep 19, 2018
tools Update cmake and doc deployment scripts Jul 17, 2018
.gitignore Resycn with qasm_simulator_cpp changes Apr 14, 2018
.pylintrc Extending valid names recognized by the linter. (#739) Aug 10, 2018
.travis.yml Add new travis stage and IMB Q badge Aug 1, 2018
CHANGELOG.rst Parallel tools and compiling (#701) Sep 18, 2018
CMakeLists.txt Update QISKit to Qiskit (#634) Jul 11, 2018
LICENSE.txt Consistent license across all the project (#550) Jun 8, 2018
MANIFEST.in Add schema json files to sdist on package build Sep 4, 2018
Make.bat Consistent license across all the project (#550) Jun 8, 2018
Makefile 0.6 release notes (#867) Sep 11, 2018
README.md Update to new Q network url format (#740) Aug 9, 2018
appveyor.yml Fix dependencies: add jsonschema, remove vcrpy (#853) Sep 3, 2018
pypi.sh Update QISKit to Qiskit (#634) Jul 11, 2018
requirements-dev.txt Fix dependencies: add jsonschema, remove vcrpy (#853) Sep 3, 2018
requirements.txt Pinning to matplotlib < 3 to avoid incompatibility issues. Sep 20, 2018
setup.py.in Isolate legacy code. Sep 14, 2018

README.md

Quantum Information Science Kit (Qiskit)

PyPI Build Status Build Status IBM Q

The Quantum Information Science Kit (Qiskit for short) is a software development kit (SDK) for working with OpenQASM and the IBM Q Experience (QX).

Use Qiskit to create quantum computing programs, compile them, and execute them on one of several backends (online Real quantum processors, online simulators, and local simulators). For the online backends, Qiskit uses our python API client to connect to the IBM Q Experience.

We use GitHub issues for tracking requests and bugs. Please see the IBM Q Experience community for questions and discussion.

If you'd like to contribute to Qiskit, please take a look at our contribution guidelines.

Links to Sections:

Installation

Dependencies

At least Python 3.5 or later is needed for using Qiskit. In addition, Jupyter Notebook is recommended for interacting with the tutorials. For this reason we recommend installing the Anaconda 3 python distribution, as it comes with all of these dependencies pre-installed.

In addition, a basic understanding of quantum information is very helpful when interacting with Qiskit. If you're new to quantum, start with our User Guides!

Instructions

We encourage to install Qiskit via the PIP tool (a python package manager):

pip install qiskit

PIP will handle all dependencies automatically for us and you will always install the latest (and well-tested) version.

PIP package comes with prebuilt binaries for these platforms:

  • Linux x86_64
  • Darwin
  • Win64

If your platform is not in the list, PIP will try to build from the sources at installation time. It will require to have CMake 3.5 or higher pre-installed and at least one of the build environments supported by CMake.

If during the installation PIP doesn't succeed to build, don't worry, you will have Qiskit installed at the end but you probably couldn't take advantage of some of the high-performance components. Anyway, we always provide a python, not-so-fast alternative as a fallback.

Setup your environment

We recommend using python virtual environments to improve your experience. Refer to our Environment Setup documentation for more information.

Creating your first Quantum Program

Now that the SDK is installed, it's time to begin working with Qiskit.

We are ready to try out a quantum circuit example, which runs via the local simulator.

This is a simple example that makes an entangled state.

# Import the Qiskit SDK
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import available_backends, execute

# Create a Quantum Register with 2 qubits.
q = QuantumRegister(2)
# Create a Classical Register with 2 bits.
c = ClassicalRegister(2)
# Create a Quantum Circuit
qc = QuantumCircuit(q, c)

# Add a H gate on qubit 0, putting this qubit in superposition.
qc.h(q[0])
# Add a CX (CNOT) gate on control qubit 0 and target qubit 1, putting
# the qubits in a Bell state.
qc.cx(q[0], q[1])
# Add a Measure gate to see the state.
qc.measure(q, c)

# See a list of available local simulators
print("Local backends: ", available_backends({'local': True}))

# Compile and run the Quantum circuit on a simulator backend
job_sim = execute(qc, "local_qasm_simulator")
sim_result = job_sim.result()

# Show the results
print("simulation: ", sim_result)
print(sim_result.get_counts(qc))

In this case, the output will be:

COMPLETED
{'counts': {'00': 512, '11': 512}}

This script is available here, where we also show how to run the same program on a real quantum computer.

Executing your code on a real Quantum chip

You can also use Qiskit to execute your code on a real quantum chip. In order to do so, you need to configure the SDK for using the credentials in your IBM Q Experience account:

Configure your API token and QX credentials

  1. Create an IBM Q Experience > Account if you haven't already done so.

  2. Get an API token from the IBM Q Experience website under My Account > Advanced > API Token. This API token allows you to execute your programs with the IBM Q Experience backends. See: Example.

  3. We are now going to add the necessary credentials to QISKit. Take your token from step 2, here called MY_API_TOKEN, and pass it to the store_credentials function:

    from qiskit import store_credentials
    
    store_credentials('MY_API_TOKEN')
  4. If you have access to the IBM Q Network features, you also need to pass the url listed on your IBM Q account page to store_credentials.

After calling store_credentials(), your credentials will be stored into disk. Once they are stored, Qiskit will automatically load and use them in your program via:

from qiskit import register

register()

For more details on installing Qiskit and for alternative methods for passing the IBM QX credentials, such as using environment variables, sending them explicitly and support for the Qconfig.py method available in previous versions, please check our Qiskit documentation.

Next Steps

Now you're set up and ready to check out some of the other examples from our Tutorial repository. Start with the index tutorial and then go to the ‘Getting Started’ example. If you already have Jupyter Notebooks installed, you can copy and modify the notebooks to create your own experiments.

To install the tutorials as part of the Qiskit SDK, see the following installation details. Complete SDK documentation can be found in the doc directory and in the official Qiskit site.

More Information

For more information on how to use Qiskit, tutorial examples, and other helpful links, take a look at these resources:

Qiskit was originally developed by researchers and developers on the IBM-Q Team at IBM Research, with the aim of offering a high level development kit to work with quantum computers.

Visit the IBM Q Experience community for questions and discussions on Qiskit and quantum computing more broadly. If you'd like to contribute to Qiskit, please take a look at our contribution guidelines.

Multilanguage guide

Authors (alphabetical)

Qiskit was originally authored by Luciano Bello, Jim Challenger, Andrew Cross, Ismael Faro, Jay Gambetta, Juan Gomez, Ali Javadi-Abhari, Paco Martin, Diego Moreda, Jesus Perez, Erick Winston and Chris Wood.

And continues to grow with the help and work of many people who contribute to the project at different levels.