Skip to main content

Qiskit

Release License DOI

[!IMPORTANT] The package qiskit-terra is not going to be updated after August 15th, 2024. Since Qiskit 0.44 (released on July 27th, 2023), the qiskit meta-package only contains qiskit-terra. In Qiskit 1.0 and beyond, the meta-package architecture is removed. If you are installing or depending on qiskit-terra, consider changing that to qiskit: Either qiskit>=0.x,<1 (if you did not transition to Qiskit 1.0 yet) or qiskit>=0.x,<2 (to also include Qiskit 1.*). Read more.

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 quantum operators.

For more details on how to use Qiskit, refer to the documentation located here:

https://qiskit.org/documentation/

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:

  1. Define and build a quantum circuit that represents the quantum state
  2. Define the classical output by measurements or a set of observable operators
  3. Depending on the output, use the primitive function sampler to sample outcomes or the estimator 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 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)

For further examples of using Qiskit you can look at the tutorials in the documentation here:

https://qiskit.org/documentation/tutorials.html

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:

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.9.0 release here:

https://github.com/Qiskit/qiskit-terra/releases/tag/0.9.0

The changelog for the current release can be found in the releases tab: Releases 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. For example, you can find the release notes for the 0.9.0 release in the Qiskit documentation here:

https://qiskit.org/documentation/release_notes.html#terra-0-9

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

Apache License 2.0

Release files for qiskit-terra 0.46.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qiskit-terra 0.46.3
File Size Uploaded
qiskit_terra-0.46.3.tar.gz 5.2 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for qiskit-terra 0.46.3
File
qiskit_terra-0.46.3-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
qiskit_terra-0.46.3-cp38-abi3-win32.whl CPython 3.8 abi3 Windows x86-32 Details
qiskit_terra-0.46.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details
qiskit_terra-0.46.3-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl CPython 3.8 abi3 Linux glibc 2.17+ IBM System/390x Details
qiskit_terra-0.46.3-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl CPython 3.8 abi3 Linux glibc 2.17+ PowerPC 64-le Details
qiskit_terra-0.46.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details
qiskit_terra-0.46.3-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-32, Linux glibc 2.12+ x86-32 Details
qiskit_terra-0.46.3-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details
qiskit_terra-0.46.3-cp38-abi3-macosx_10_9_x86_64.whl CPython 3.8 abi3 macOS 10.9+ x86-64 Details
qiskit_terra-0.46.3-cp38-abi3-macosx_10_9_universal2.whl CPython 3.8 abi3 macOS 10.9+ universal2 (ARM64, x86-64) Details

Total release size:60.7 MB

Release files / qiskit_terra-0.46.3.tar.gz

Download URL qiskit_terra-0.46.3.tar.gz
Size 5.2 MB
Tags Source
SHA-256 checksum
How to use checksums
48e0e193e322fe9ee7201a8f8a7b8e3dd463c4804e64c36a733d7ad34acdddb7
BLAKE2b-256 checksum
How to use checksums
e3277d4882c6bdce5c22b93b07533b9357a94a1010f9e563b1213e9d71478d43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / qiskit_terra-0.46.3-cp38-abi3-win_amd64.whl

Download URL qiskit_terra-0.46.3-cp38-abi3-win_amd64.whl
Size 5.2 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ffd5ddc808e7780c49c085287608150d7e64748a6d874cf1a333f1ecc2781d37
BLAKE2b-256 checksum
How to use checksums
9831bb89a69575820815d0256055bb1abcd4d67d537c36305b6cbdca60a7145e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / qiskit_terra-0.46.3-cp38-abi3-win32.whl

Download URL qiskit_terra-0.46.3-cp38-abi3-win32.whl
Size 5.1 MB
Tags CPython 3.8 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
e4d45ed4262478c7c2db187376608488e7c5b38fed399470e7e91f2412605c5f
BLAKE2b-256 checksum
How to use checksums
3413be6cbba39ba1d4129087c82535c81c5821879a332829c9d6f5f6797318d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / qiskit_terra-0.46.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL qiskit_terra-0.46.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.4 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
80f06b9bdd095d7cb16482d0baa0b081163b05fafd9ca1ab782b1769bee8213c
BLAKE2b-256 checksum
How to use checksums
e1f91531226e78a46e7ef6108b844531ccaa4880345314614941a2da8cd77794
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / qiskit_terra-0.46.3-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl

Download URL qiskit_terra-0.46.3-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Size 5.9 MB
Tags CPython 3.8 Linux glibc 2.17+ IBM System/390x abi3
SHA-256 checksum
How to use checksums
16509c43f2e673d3f2be4760d02a5b79799416f133a322b043bd65da1a08be58
BLAKE2b-256 checksum
How to use checksums
44767f93e3a81f4241546251fa3ea3386dbaddcc9f93c81122c373b406352944
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / qiskit_terra-0.46.3-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl

Download URL qiskit_terra-0.46.3-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Size 5.5 MB
Tags CPython 3.8 Linux glibc 2.17+ PowerPC 64-le abi3
SHA-256 checksum
How to use checksums
a8a2b6b49772310297032e0f3f30f33f3520dca6f7fae17c4f7b73f6f91c897f
BLAKE2b-256 checksum
How to use checksums
650a1d2fe43fa14e12d8f3bb599322f7a74d68c3b497725aa43dc0f15019e199
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / qiskit_terra-0.46.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL qiskit_terra-0.46.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 5.4 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
997edd073f701173fe1a36fda00247664f23f17e596b3d6737fffea7ef761424
BLAKE2b-256 checksum
How to use checksums
d9bec6e25ca59139512d418ae2a5933c33e3ecade3e1dd7e1a5b21ed76118fcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / qiskit_terra-0.46.3-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl

Download URL qiskit_terra-0.46.3-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Size 5.5 MB
Tags CPython 3.8 Linux glibc 2.12+ x86-32 Linux glibc 2.17+ x86-32 abi3
SHA-256 checksum
How to use checksums
baf4c44f5d4d9f82d053e316dfbb039a9a3057198bf413dea0ee29e0a5b59e11
BLAKE2b-256 checksum
How to use checksums
3943e4e2ba2e5e33100432b7c7166b41d6fa92edb5a46681f58af1e75fea15fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / qiskit_terra-0.46.3-cp38-abi3-macosx_11_0_arm64.whl

Download URL qiskit_terra-0.46.3-cp38-abi3-macosx_11_0_arm64.whl
Size 5.4 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
cfad66321ac0938dccea334eb049dc6288790cecc39fb85d5c9c473525b3565d
BLAKE2b-256 checksum
How to use checksums
610040d7509e3852f869b62cda3509af0be3e33f7fcfac92b6778df843705e9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / qiskit_terra-0.46.3-cp38-abi3-macosx_10_9_x86_64.whl

Download URL qiskit_terra-0.46.3-cp38-abi3-macosx_10_9_x86_64.whl
Size 5.5 MB
Tags CPython 3.8 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
fd1f31571f3a832928692dcf3945e16b64c87ccd70f68739a16d3d2fb95e64d4
BLAKE2b-256 checksum
How to use checksums
80bd2b74f586759134eb76a06ed40925be1a9d0fbc186b3172f0b383b75f6bbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / qiskit_terra-0.46.3-cp38-abi3-macosx_10_9_universal2.whl

Download URL qiskit_terra-0.46.3-cp38-abi3-macosx_10_9_universal2.whl
Size 6.4 MB
Tags CPython 3.8 abi3 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
3e6313e03706be8f35551e2abe950006047a09d037c96bc8d2907081b548e91b
BLAKE2b-256 checksum
How to use checksums
bb5dbebf97df13de1765280c064ec6d9810435850a3bb5d99e7fadda4260ac53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.46.3 This release

11 release files

0.9.1

16 release files

0.9.0

16 release files

0.8.2

16 release files

0.8.1

16 release files

0.7.0

10 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page