An open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
Reason this release was yanked:
QPY parsing of symengine payloads is broken if there is a symengine version mismatch.
Project description
Qiskit
Qiskit is an open-source 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 operators.
For more details on how to use Qiskit, refer to the documentation located here:
Installation
[!WARNING] Do not try to upgrade an existing Qiskit 0.* environment to Qiskit 1.0 in-place. Read more.
We encourage installing Qiskit via pip
:
pip install qiskit
Pip will handle all dependencies automatically and you will always install the latest (and well-tested) 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) # 0th-qubit-Controlled-NOT gate on 1st qubit
qc_example.cx(0,2) # 0th-qubit-Controlled-NOT gate on 2nd qubit
This simple example makes an entangled state known as a GHZ state $(|000\rangle + i|111\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+YXX-YYY$ 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 single-qubit operator X and Y
and see if you can achieve this outcome. (Spoiler alert: this is not possible!)
Using the Qiskit-provided 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 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 post-processing, 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 lower-level 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 post-processing and return outcomes that are vendor-defined. Some examples of published provider packages that interface with real hardware are:
- https://github.com/qiskit-community/qiskit-ionq
- https://github.com/qiskit-community/qiskit-aqt-provider
- https://github.com/qiskit-community/qiskit-braket-provider
- https://github.com/qiskit-community/qiskit-quantinuum-provider
- https://github.com/rigetti/qiskit-rigetti
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, Co-design Center for Quantum Advantage (C2QA) under contract number DE-SC0012704.
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
File details
Details for the file qiskit-1.2.3.tar.gz
.
File metadata
- Download URL: qiskit-1.2.3.tar.gz
- Upload date:
- Size: 3.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25ffa5fc21776695ded07c0f016d83de54abfbba6c74d5479068dacd3f246098 |
|
MD5 | 61ca0ef85ce78fbdb819a7474cb0bfb4 |
|
BLAKE2b-256 | 4aa17b0186d2dc75dfa2b131679ad64685fcf4769cc3f86d076da1e49acb89ed |
File details
Details for the file qiskit-1.2.3-cp38-abi3-win_amd64.whl
.
File metadata
- Download URL: qiskit-1.2.3-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 4.6 MB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d72c22e0ec1b0c24a654ac4f18f5a177050cddd0c45c3170670ce2732df759b7 |
|
MD5 | 8e0c80d8d1961dd367d217c287515092 |
|
BLAKE2b-256 | 1abdd9f0fb6eb8d7e4d6be1edca869f60fb0f3f91925a91af59fcf72e3359a75 |
File details
Details for the file qiskit-1.2.3-cp38-abi3-win32.whl
.
File metadata
- Download URL: qiskit-1.2.3-cp38-abi3-win32.whl
- Upload date:
- Size: 4.4 MB
- Tags: CPython 3.8+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c96a81b133d972c37a38480efe487595dddef5675aba330d4680288536538b03 |
|
MD5 | e9445ba2501e166160716521c5b992eb |
|
BLAKE2b-256 | d728195d602da63fdec24f1d59fc495431d57069cca99cd289bd13f940f21634 |
File details
Details for the file qiskit-1.2.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: qiskit-1.2.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.7 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9387ee200c18e4073c2e01261f506bb2fd94ad8e42a4c5b09f26e8abc8fc789a |
|
MD5 | 9b8b3a3c824da16a3805bcd9f0a30437 |
|
BLAKE2b-256 | f0bb3ae34cbe124baecbec749119abb4cb8eadf9c834fb1f1ccb43d7e8ec39d1 |
File details
Details for the file qiskit-1.2.3-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
.
File metadata
- Download URL: qiskit-1.2.3-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 5.5 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6fe2c4e657c0bca53fcd0528c6c56841d60e5efdca3361ef4f1b7158896f091 |
|
MD5 | 4bd8ecbc062b459ea35ff40c69e26f82 |
|
BLAKE2b-256 | f324097ce6469564b5c1ff111bb31425807c6246df13c5870b895e668682a4c7 |
File details
Details for the file qiskit-1.2.3-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
.
File metadata
- Download URL: qiskit-1.2.3-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 4.7 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbc9133c5a26a5285bca37bddd1a57e3ea23f7b32612552eb3cb224dae2235ca |
|
MD5 | 717241b0ad40121c47fb00d9c3309c6c |
|
BLAKE2b-256 | 0aa4c28c424ef9e45f9b44d968d01b5a74b64947f9bb561497b6def4a899632c |
File details
Details for the file qiskit-1.2.3-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: qiskit-1.2.3-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 4.8 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1b5a28327c352a1fd3b7300816bb165cedf5d348f4021c3d23529e0ae5ee331 |
|
MD5 | 53fe8f4e880c508b6ca3778138837e97 |
|
BLAKE2b-256 | 26a07b873c66a318b9b543fcf17535d027a99c7791d54e76837bdb5ba80cfed3 |
File details
Details for the file qiskit-1.2.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: qiskit-1.2.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 4.6 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 190bd69700fc5ee1c6e630fceb9aa75ddb988abab956763a85f01f27f12bcda1 |
|
MD5 | e98c0470656480291dd298c0c23cac83 |
|
BLAKE2b-256 | 945ab843845b253176e187d511a99af8e0ae826d9816d435eaabe9d0a8a90cc4 |
File details
Details for the file qiskit-1.2.3-cp38-abi3-macosx_11_0_arm64.whl
.
File metadata
- Download URL: qiskit-1.2.3-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.5 MB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0e1f4fccf2990123e2e5d34457264a1840eceeb8117371862146cec8b805d60 |
|
MD5 | 8e19023b383000d9a5312e5ca337638c |
|
BLAKE2b-256 | c203c168bcf6b5868d1d5acb7eff404a3de1cc5094401440e689bf2352b2d835 |
File details
Details for the file qiskit-1.2.3-cp38-abi3-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: qiskit-1.2.3-cp38-abi3-macosx_10_9_x86_64.whl
- Upload date:
- Size: 4.6 MB
- Tags: CPython 3.8+, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14902afd0ff2ea579d6d6a51a412c3170aa1d464468b5cb9d6970cccd329e440 |
|
MD5 | f2ea30811206da013430f98b971f108c |
|
BLAKE2b-256 | 4f24bb2cfba8f7f61f12b223e39f8007e5be1fade7da72799d3bdb6951c6eafa |
File details
Details for the file qiskit-1.2.3-cp38-abi3-macosx_10_9_universal2.whl
.
File metadata
- Download URL: qiskit-1.2.3-cp38-abi3-macosx_10_9_universal2.whl
- Upload date:
- Size: 6.8 MB
- Tags: CPython 3.8+, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c3201a9fbfa93aa6b2779fb06417a2b323b2aedfc2d5f3e9de4eb0c87b9c616 |
|
MD5 | fd60c2be1d076680c2773bd57d53159d |
|
BLAKE2b-256 | ebc4f2868f8cf2d3702e85a20687fc823a3307aea2a2f9275db9297df2add382 |