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

Downloads Coverage Status PyPI - Python Version Minimum rustc 1.70 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 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, 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.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

Download files

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

Source Distribution

qiskit-1.4.6.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-1.4.6-cp39-abi3-win_amd64.whl (6.5 MB view details)

Uploaded CPython 3.9+Windows x86-64

qiskit-1.4.6-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (6.7 MB view details)

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

qiskit-1.4.6-cp39-abi3-manylinux2014_s390x.manylinux_2_17_s390x.whl (6.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ s390x

qiskit-1.4.6-cp39-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl (6.9 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ppc64le

qiskit-1.4.6-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (6.5 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

qiskit-1.4.6-cp39-abi3-macosx_11_0_arm64.whl (6.2 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

qiskit-1.4.6-cp39-abi3-macosx_10_12_x86_64.whl (6.5 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for qiskit-1.4.6.tar.gz
Algorithm Hash digest
SHA256 e004df4eb0a4bba61e75e6b1d71813341b35f04ccb49673fe62df3ff7f79ba2b
MD5 8f9f4e794ea86f57733b4e0beb48fc13
BLAKE2b-256 365200703630afd3b072283eeb1eab5f9ccda2b6d9f3e94c9b2ba776cd33fae1

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.4.6.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-1.4.6-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: qiskit-1.4.6-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 6.5 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qiskit-1.4.6-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a225d3a608eb6382ed49747a737539cf6d464eb202e7a5d7a910f54673882362
MD5 6460dbbd19cda9f5b364f14be8aee6da
BLAKE2b-256 f8acb3dbaf4b1c9daa9a35e72b0cccb10dc8d4fd5742e6b8f091864d02802600

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.4.6-cp39-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-1.4.6-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for qiskit-1.4.6-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 4b7564cba22879a5b03c42d957315561289d9b8ec8f35358d3a0e7289c5e63e4
MD5 f370bf6510a65044ace589f433598c1b
BLAKE2b-256 dc3dd7ef971bc2afb22c40bf4f6502f424692aaaeb9e79fcc97ee2b51e8ae7e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.4.6-cp39-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-1.4.6-cp39-abi3-manylinux2014_s390x.manylinux_2_17_s390x.whl.

File metadata

File hashes

Hashes for qiskit-1.4.6-cp39-abi3-manylinux2014_s390x.manylinux_2_17_s390x.whl
Algorithm Hash digest
SHA256 43cc65fe0687db724316fcad80bdf3c87d0b3de2312f3eaef261e0e5be2b09a9
MD5 815f0eef87f28e2b77082647b6dde6ed
BLAKE2b-256 fae749bec214923d56363ebb8aaa80b23329101bd5b1dde8a9f1bb98a7f1233c

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.4.6-cp39-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-1.4.6-cp39-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl.

File metadata

File hashes

Hashes for qiskit-1.4.6-cp39-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl
Algorithm Hash digest
SHA256 b5fad89888ebd151e9de678ed84ca7da7e56d633d8f30c02fdd1e101315a7771
MD5 aaff693ba869017035a21370d2e31d8b
BLAKE2b-256 e027944622c73215e59233b1c90e61a0b27ab55467805bfe164687918c25becd

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.4.6-cp39-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-1.4.6-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for qiskit-1.4.6-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 10aad28459e7f13d77f6d87e881c94d4d8a9a402e552a095eb325a9fbf86e9f2
MD5 c559487a06af6fd34aa4c8974e0069df
BLAKE2b-256 6596c775b2f323da6d962927249bacb2a1582dd8349376b9b3a40c9b79c52b5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.4.6-cp39-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-1.4.6-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qiskit-1.4.6-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 17d5b9d40885d11bfccca6e58b05e5d82023662a8f551cd0154222695d4aef01
MD5 0b5b65fcf2530338ddfbcdf82abcd8b8
BLAKE2b-256 d60c57a0a6d60bcbb90fb1152f1e445ba80f3678aaa7ba98c9917ad12a32e691

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.4.6-cp39-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-1.4.6-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for qiskit-1.4.6-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0eaf611bc3bcb6e1ef1022b45cd0d5b47ad719c66408af21d0cdd0bdc2c65d8b
MD5 e2b74583df2fd21af34f7b5eeab43245
BLAKE2b-256 d66fac6559a9814e89268349ea59893b1e3bff3d873fdbf358e7924b8f3b939b

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.4.6-cp39-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