Skip to main content

An open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.

Project description

Qiskit

License Current Release Extended Support Release Downloads Coverage Status PyPI - Python Version Minimum rustc 1.85 Downloads DOI

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:

https://quantum.cloud.ibm.com/docs/

Installation

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 Sampler primitive to sample outcomes or the Estimator primitive to estimate expectation 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> / √2
qc = QuantumCircuit(3)
qc.h(0)             # generate superposition
qc.p(np.pi / 2, 0)  # add quantum phase
qc.cx(0, 1)         # 0th-qubit-Controlled-NOT gate on 1st qubit
qc.cx(0, 2)         # 0th-qubit-Controlled-NOT gate on 2nd qubit

This simple example creates 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 you will use. Starting with the 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.measure_all(inplace=False)

# 3. Execute using the Sampler primitive
from qiskit.primitives import StatevectorSampler
sampler = StatevectorSampler()
job = sampler.run([qc_measured], shots=1000)
result = job.result()
print(f" > Counts: {result[0].data['meas'].get_counts()}")

Running this will give an outcome similar to {'000': 497, '111': 503} which is 000 50% of the time and 111 50% of the time up to statistical fluctuations. To illustrate the power of the 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 that the Estimator requires a circuit without measurements, so we use the qc 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 StatevectorEstimator
estimator = StatevectorEstimator()
job = estimator.run([(qc, operator)], precision=1e-3)
result = job.result()
print(f" > Expectation values: {result[0].data.evs}")

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.StatevectorSampler and qiskit.primitives.StatevectorEstimator 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 bidirectional linear chain of qubits $0 \leftrightarrow 1 \leftrightarrow 2$ with the coupling_map = [[0, 1], [1, 0], [1, 2], [2, 1]].

from qiskit import transpile
from qiskit.transpiler import Target, CouplingMap
target = Target.from_configuration(
    basis_gates=["cz", "sx", "rz"],
    coupling_map=CouplingMap.from_line(3),
)
qc_transpiled = transpile(qc, target=target)

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.BaseSamplerV2 and qiskit.primitives.BaseEstimatorV2 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 1.2.0 release here:

https://github.com/Qiskit/qiskit/releases/tag/1.2.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. 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

Apache License 2.0

Project details


Release history Release notifications | RSS feed

This version

2.3.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qiskit-2.3.0.tar.gz (3.9 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

qiskit-2.3.0-cp310-abi3-win_amd64.whl (8.6 MB view details)

Uploaded CPython 3.10+Windows x86-64

qiskit-2.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

qiskit-2.3.0-cp310-abi3-manylinux2014_s390x.manylinux_2_17_s390x.whl (8.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ s390x

qiskit-2.3.0-cp310-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl (9.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ppc64le

qiskit-2.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (8.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

qiskit-2.3.0-cp310-abi3-macosx_11_0_arm64.whl (7.9 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

qiskit-2.3.0-cp310-abi3-macosx_10_12_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file qiskit-2.3.0.tar.gz.

File metadata

  • Download URL: qiskit-2.3.0.tar.gz
  • Upload date:
  • Size: 3.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qiskit-2.3.0.tar.gz
Algorithm Hash digest
SHA256 e0a00c6681b8d04171c5cdb928837d992676f8aa4a07c390d446e54babaf6c1e
MD5 614c8cca9b78d6881bd3bd98d1cdda7f
BLAKE2b-256 138ed5279454717d780f32eec4dfa6a7ef256ea7382b2f8fef2c715fc6f1180e

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-2.3.0.tar.gz:

Publisher: wheels.yml on Qiskit/qiskit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qiskit-2.3.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: qiskit-2.3.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 8.6 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qiskit-2.3.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8679a426725785701629f0af905a7a5b6bc25b0dcd7fe4f4c9f8be63d89e832c
MD5 24c26c3f4a3469f8657117af41ccc2cf
BLAKE2b-256 c3bb0fbcf43f9daba43f1eb31ecf7d36afcbcf705457d9df6e8e6f38f07b4851

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-2.3.0-cp310-abi3-win_amd64.whl:

Publisher: wheels.yml on Qiskit/qiskit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qiskit-2.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for qiskit-2.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 24fd70ee3ac47fe029096e39b1c39abf3e7f145c723df90f9600468099c12aa4
MD5 eb9f014cdac920ddbe7085de2ed69060
BLAKE2b-256 de22fd8e7d4869641f60d9b7ce6d688b59520c8c8be8c8e4b51d76fb85b59f42

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-2.3.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:

Publisher: wheels.yml on Qiskit/qiskit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qiskit-2.3.0-cp310-abi3-manylinux2014_s390x.manylinux_2_17_s390x.whl.

File metadata

File hashes

Hashes for qiskit-2.3.0-cp310-abi3-manylinux2014_s390x.manylinux_2_17_s390x.whl
Algorithm Hash digest
SHA256 ae0b1ec4c24ff8867599a5e8a46efaaf6d5477d1c4533427b7ae516054f52b2f
MD5 3d3d403fb9065817b01f2091c21ada72
BLAKE2b-256 739f478788b16f653cdf151c7f2f040ba41b97e355d3bf9348ee2f0f685a5ea6

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-2.3.0-cp310-abi3-manylinux2014_s390x.manylinux_2_17_s390x.whl:

Publisher: wheels.yml on Qiskit/qiskit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qiskit-2.3.0-cp310-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl.

File metadata

File hashes

Hashes for qiskit-2.3.0-cp310-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl
Algorithm Hash digest
SHA256 7c413dace7a9b1d30bbbfeb2f90c4564dfcf6ed3c0744e026d4aca84f8fbd2bb
MD5 66eaec099a6fc64f4a5e567cdb82e855
BLAKE2b-256 547633ee3519c3ff88b6154ccce13d24a33c0dc0fc9b22df8f216f1833cb0981

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-2.3.0-cp310-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl:

Publisher: wheels.yml on Qiskit/qiskit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qiskit-2.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for qiskit-2.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 b437262a14ab961703153f79f38de5fde408601b0eda1f9c34b57498c912ef33
MD5 dbcac883a5c96e6b37b0f5501dc64dce
BLAKE2b-256 d1c6d928648d417c5c2e0c50481ef4f197f2ad8ca74d361e163e0c5d73253cbf

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-2.3.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl:

Publisher: wheels.yml on Qiskit/qiskit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qiskit-2.3.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qiskit-2.3.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5f29f3b6a2b5738463bc667ddb2bcc79a83fb434ab9a8033487b64a399f71bef
MD5 807f3d0ade88e7e6f5f2bc6f8dce8d9e
BLAKE2b-256 d755bb8efb2b6e46e5b8c7d147973646fa71677e63ecd2378af4db2829795be6

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-2.3.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: wheels.yml on Qiskit/qiskit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qiskit-2.3.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for qiskit-2.3.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 bfeba21f216f64b051f9ac98653e9999d4c1bcb4f328aca06ad059aaef86586b
MD5 c0266ae793b2738ef870d4d98cb9a5d4
BLAKE2b-256 d67922a6c61a94fef8eac09f968355c15c0d3b0800110152bbcf9cbed5bfc807

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-2.3.0-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: wheels.yml on Qiskit/qiskit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page