An opensource SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
Project description
Qiskit
Qiskit is an opensource SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
This library is the core component of Qiskit, which contains the building blocks for creating and working with quantum circuits, quantum operators, and primitive functions (sampler and estimator). It also contains a transpiler that supports optimizing quantum circuits and a quantum information toolbox for creating advanced quantum operators.
For more details on how to use Qiskit, refer to the documentation located here:
Installation
We encourage installing Qiskit via pip
:
pip install qiskit
Pip will handle all dependencies automatically and you will always install the latest (and welltested) version.
To install from source, follow the instructions in the documentation.
Create your first quantum program in Qiskit
Now that Qiskit is installed, it's time to begin working with Qiskit. The essential parts of a quantum program are:
 Define and build a quantum circuit that represents the quantum state
 Define the classical output by measurements or a set of observable operators
 Depending on the output, use the primitive function
sampler
to sample outcomes or theestimator
to estimate values.
Create an example quantum circuit using the QuantumCircuit
class:
import numpy as np
from qiskit import QuantumCircuit
# 1. A quantum circuit for preparing the quantum state 000> + i 111>
qc_example = QuantumCircuit(3)
qc_example.h(0) # generate superpostion
qc_example.p(np.pi/2,0) # add quantum phase
qc_example.cx(0,1) # 0thqubitControlledNOT gate on 1st qubit
qc_example.cx(0,2) # 0thqubitControlledNOT gate on 2nd qubit
This simple example makes an entangled state known as a GHZ state $(000\rangle + i111\rangle)/\sqrt{2}$. It uses the standard quantum gates: Hadamard gate (h
), Phase gate (p
), and CNOT gate (cx
).
Once you've made your first quantum circuit, choose which primitive function you will use. Starting with sampler
,
we use measure_all(inplace=False)
to get a copy of the circuit in which all the qubits are measured:
# 2. Add the classical output in the form of measurement of all qubits
qc_measured = qc_example.measure_all(inplace=False)
# 3. Execute using the Sampler primitive
from qiskit.primitives.sampler import Sampler
sampler = Sampler()
job = sampler.run(qc_measured, shots=1000)
result = job.result()
print(f" > Quasi probability distribution: {result.quasi_dists}")
Running this will give an outcome similar to {0: 0.497, 7: 0.503}
which is 000
50% of the time and 111
50% of the time up to statistical fluctuations.
To illustrate the power of Estimator, we now use the quantum information toolbox to create the operator $XXY+XYX+YXXYYY$ and pass it to the run()
function, along with our quantum circuit. Note the Estimator requires a circuit without measurement, so we use the qc_example
circuit we created earlier.
# 2. define the observable to be measured
from qiskit.quantum_info import SparsePauliOp
operator = SparsePauliOp.from_list([("XXY", 1), ("XYX", 1), ("YXX", 1), ("YYY", 1)])
# 3. Execute using the Estimator primitive
from qiskit.primitives import Estimator
estimator = Estimator()
job = estimator.run(qc_example, operator, shots=1000)
result = job.result()
print(f" > Expectation values: {result.values}")
Running this will give the outcome 4
. For fun, try to assign a value of +/ 1 to each singlequbit operator X and Y
and see if you can achieve this outcome. (Spoiler alert: this is not possible!)
Using the Qiskitprovided qiskit.primitives.Sampler
and qiskit.primitives.Estimator
will not take you very far. The power of quantum computing cannot be simulated
on classical computers and you need to use real quantum hardware to scale to larger quantum circuits. However, running a quantum
circuit on hardware requires rewriting them to the basis gates and connectivity of the quantum hardware.
The tool that does this is the transpiler
and Qiskit includes transpiler passes for synthesis, optimization, mapping, and scheduling. However, it also includes a
default compiler which works very well in most examples. The following code will map the example circuit to the basis_gates = ['cz', 'sx', 'rz']
and a linear chain of qubits $0 \rightarrow 1 \rightarrow 2$ with the coupling_map =[[0, 1], [1, 2]]
.
from qiskit import transpile
qc_transpiled = transpile(qc_example, basis_gates = ['cz', 'sx', 'rz'], coupling_map =[[0, 1], [1, 2]] , optimization_level=3)
Executing your code on real quantum hardware
Qiskit provides an abstraction layer that lets users run quantum circuits on hardware from any vendor that provides a compatible interface.
The best way to use Qiskit is with a runtime environment that provides optimized implementations of sampler
and estimator
for a given hardware platform. This runtime may involve using pre and postprocessing, such as optimized transpiler passes with error suppression, error mitigation, and, eventually, error correction built in. A runtime implements qiskit.primitives.BaseSampler
and qiskit.primitives.BaseEstimator
interfaces. For example,
some packages that provide implementations of a runtime primitive implementation are:
Qiskit also provides a lowerlevel abstract interface for describing quantum backends. This interface, located in
qiskit.providers
, defines an abstract BackendV2
class that providers can implement to represent their
hardware or simulators to Qiskit. The backend class includes a common interface for executing circuits on the backends; however, in this interface each provider may perform different types of pre and postprocessing and return outcomes that are vendordefined. Some examples of published provider packages that interface with real hardware are:
 https://github.com/Qiskit/qiskitibmprovider
 https://github.com/qiskitcommunity/qiskitionq
 https://github.com/qiskitcommunity/qiskitaqtprovider
 https://github.com/qiskitcommunity/qiskitbraketprovider
 https://github.com/qiskitcommunity/qiskitquantinuumprovider
 https://github.com/rigetti/qiskitrigetti
You can refer to the documentation of these packages for further instructions on how to get access and use these systems.
Contribution Guidelines
If you'd like to contribute to Qiskit, please take a look at our contribution guidelines. By participating, you are expected to uphold our code of conduct.
We use GitHub issues for tracking requests and bugs. Please
join the Qiskit Slack community for discussion, comments, and questions.
For questions related to running or using Qiskit, Stack Overflow has a qiskit
.
For questions on quantum computing with Qiskit, use the qiskit
tag in the Quantum Computing Stack Exchange (please, read first the guidelines on how to ask in that forum).
Authors and Citation
Qiskit is the work of many people who contribute to the project at different levels. If you use Qiskit, please cite as per the included BibTeX file.
Changelog and Release Notes
The changelog for a particular release is dynamically generated and gets
written to the release page on Github for each release. For example, you can
find the page for the 0.46.0
release here:
https://github.com/Qiskit/qiskit/releases/tag/0.46.0
The changelog for the current release can be found in the releases tab: The changelog provides a quick overview of notable changes for a given release.
Additionally, as part of each release, detailed release notes are written to document in detail what has changed as part of a release. This includes any documentation on potential breaking changes on upgrade and new features. See all release notes here.
Acknowledgements
We acknowledge partial support for Qiskit development from the DOE Office of Science National Quantum Information Science Research Centers, Codesign Center for Quantum Advantage (C2QA) under contract number DESC0012704.
License
Project details
Release history Release notifications  RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for qiskit1.0.1cp38abi3win_amd64.whl
Algorithm  Hash digest  

SHA256  c78c6dc45f5dfd9596ff44f2f106db7e2bdd3c220cbcd4117e2c6edee99346b5 

MD5  989c56b6554f160d93180e8628c79608 

BLAKE2b256  f34706ec3eccd0e6e59604ca6fafa2b7c3cacce7d3de040c1c272e3d87c50e39 
Hashes for qiskit1.0.1cp38abi3win32.whl
Algorithm  Hash digest  

SHA256  dd812ddd32374b1de80530156ce72a78556e72d7b1772c6e1037497b31e06487 

MD5  4687321c835532dc95866011afe81207 

BLAKE2b256  2cc0921e0dbdb81b9b98f9cba3e3196ee4a71a9867f31c0ca9cb707a7c15fe88 
Hashes for qiskit1.0.1cp38abi3manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm  Hash digest  

SHA256  490e8e46e37a452a6a3ffca942191676d78329a44c9cf8a18308e16c51c5d7ad 

MD5  b68ce6cee1143bfbeab60a026f187887 

BLAKE2b256  33cf91090452d62e661ef982ca9170b0aedc5ce793ef1cd6cd9ed6d3809d4cc6 
Hashes for qiskit1.0.1cp38abi3manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm  Hash digest  

SHA256  93973df6a9e89ee2aabbea0d9cc6962752245dae0f2a04a8a60c92427ae2dd5d 

MD5  7728ba56c3aa3dd9ceb48f7f1a188970 

BLAKE2b256  558f19da82116e237e7406a8f3a22a8db8dd532cdb46996bb4482a2429e7bedd 
Hashes for qiskit1.0.1cp38abi3manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm  Hash digest  

SHA256  d989899c5bd3a74c984d5e8b2c43b8b31f945906c02274edc94f2eb33a115e40 

MD5  c6a36f0da6669a1c2420cb2dae7c22af 

BLAKE2b256  f61a1c88209ea5f3f19e896cc3662faaa7bd9fc045b02bb170fc848d32cca816 
Hashes for qiskit1.0.1cp38abi3manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm  Hash digest  

SHA256  a6bd328b504691d32220c177484a17e0f49b285d893e36a028456073d2b4b10a 

MD5  a64d7b0e5f9139add2bcb4a630bda758 

BLAKE2b256  0f22c2e6cca2e417b9ff7154c675d04d7d115d673b531871ab3f2365f6f1f537 
Hashes for qiskit1.0.1cp38abi3manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm  Hash digest  

SHA256  317f34e2a33192d299a16aea06c81c7b8f6070efe49b36f0c143285ff98fd069 

MD5  9452a77a8cde7a034d47ec93c0960067 

BLAKE2b256  a09e4b9fb1783af125775eb95d19370b69b45c2fc27c3f5eb540996dac34dda0 
Hashes for qiskit1.0.1cp38abi3macosx_11_0_arm64.whl
Algorithm  Hash digest  

SHA256  d09def183c8a25cec00cf11c41889818d084a6df94d183c1d5268ba9e966aa83 

MD5  91c7b9a7685fcc48803a536ea00471b7 

BLAKE2b256  9e5edfaec070730a54f64a8e3bb7162e0a765bc171e3ab28e541a7eb5aa0d2f0 
Hashes for qiskit1.0.1cp38abi3macosx_10_9_x86_64.whl
Algorithm  Hash digest  

SHA256  04b58f3aa9b76b572efc6416aca4de6d737907738cb7bd02f90aa0ca7c992f1d 

MD5  1856b09946a8fb43c5f6c0ca199fab71 

BLAKE2b256  0e78418ee7cc502dd6938fbbb261284789ea2fb14144a61f01a26c403e34a254 
Hashes for qiskit1.0.1cp38abi3macosx_10_9_universal2.whl
Algorithm  Hash digest  

SHA256  1cfdec75cbef97d064b619d74c2d1b3c39645f3d5956d7f6889e27e621a9ea95 

MD5  36f07ea22ceb62f92eea182206ed33cb 

BLAKE2b256  c93e48b5982b0cc7364f40b4bc56d626c9f0020bd82069c92778bf6b845bf4d6 