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.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://docs.quantum.ibm.com/

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 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:

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: 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.3.0rc2.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.3.0rc2-cp39-abi3-win_amd64.whl (6.5 MB view details)

Uploaded CPython 3.9+Windows x86-64

qiskit-1.3.0rc2-cp39-abi3-win32.whl (6.1 MB view details)

Uploaded CPython 3.9+Windows x86

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

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

qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (7.9 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ s390x

qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (6.7 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ppc64le

qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (6.7 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ i686

qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

qiskit-1.3.0rc2-cp39-abi3-macosx_10_9_x86_64.whl (6.5 MB view details)

Uploaded CPython 3.9+macOS 10.9+ x86-64

File details

Details for the file qiskit-1.3.0rc2.tar.gz.

File metadata

  • Download URL: qiskit-1.3.0rc2.tar.gz
  • Upload date:
  • Size: 3.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for qiskit-1.3.0rc2.tar.gz
Algorithm Hash digest
SHA256 8ff47ddde7bb87b0ac719638611f332d0fa9315b18d73d1410dc01cb41bb08e8
MD5 9547d7e552862f351b04c2069a96ecf9
BLAKE2b-256 37a1c2cf5e27bc6756d5687ac6bf7deda268d85763e8ef1fae1f6e6da00f4f19

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: qiskit-1.3.0rc2-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/5.1.1 CPython/3.12.7

File hashes

Hashes for qiskit-1.3.0rc2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6d5002ab04b96f90aab7e23597f82962d2a560ff95096a1a358e0a1b61f12c01
MD5 ec70e82d5fcc50e363a91f50f5800a3e
BLAKE2b-256 6a091dde3c5e35ce0de1a68fc6458c64d7f7a87a1cb2332a1da0ef93833f142d

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.3.0rc2-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.3.0rc2-cp39-abi3-win32.whl.

File metadata

  • Download URL: qiskit-1.3.0rc2-cp39-abi3-win32.whl
  • Upload date:
  • Size: 6.1 MB
  • Tags: CPython 3.9+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for qiskit-1.3.0rc2-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 6b56160b3db7fa224314c6131ce9ef306dc002daa5b0e689420a583ade643041
MD5 d13418dea4bfec68e109451fc54da35c
BLAKE2b-256 18f2078c4a97af474022ed11f21b1bad571b98a8d7b7afc67433f9e092384f2a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dff52d1c3c7271d5db7a5ad455eb79a11e072d5b2803ca3536d081d63424adae
MD5 a9dfa2de535f9a00d595c7a8901e6a91
BLAKE2b-256 92c38024e970d9d5f4d75a226a2bc78bc93a5a00747214aafe632f3b5f6e4675

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_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.3.0rc2-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 55f8c54329344fc74c618a0e8f036336fd2e06be983bf97427b2ddbd9bb29983
MD5 cc6e9a2e1c43e033a38aefc519ed9933
BLAKE2b-256 01f9a5ff5a68124ca614ef0c86224ae6ea942006d6661e6058074d8012bd522f

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_s390x.manylinux2014_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.3.0rc2-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 a8433a49b444d23965a91a632ef2aaa85c8a4afe761c7799e81bc049586307f5
MD5 d1b00a23fbf3fc2e1417b54f99832468
BLAKE2b-256 dba4ec744cc29c40ec1e10702f32effe9700908a4cf0a91ed31f70477adab7a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_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.3.0rc2-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 9dbab9523e4f8e33162ecafc0d7df4c5827bd4c8ebfb1b8a7a6b78383160586e
MD5 ebcc4656d383c7870d0ae2b166e3c426
BLAKE2b-256 121c060c2ba0b9f00d32b782762eb3b581cbf8ce83eaf9187943a12fbe54dd1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.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.3.0rc2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0a70541404a849044750cb618d4a8942d84bbb28f9056d22f71fe0aa0c3bd484
MD5 9608ac2606211ac8022a8d8e2b08b3d6
BLAKE2b-256 c1cf2161b356bf587fe101299857cc7fae79f97feeb9bf4e18d22b3a164d7e16

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.3.0rc2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_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.3.0rc2-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qiskit-1.3.0rc2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f9ef31232c589fcfd09801dd613768571f1239a35e8545e5ce6b735067d16944
MD5 e700e9a02358814e6dc861e088b25f02
BLAKE2b-256 572177fce41dddc41ba4a48b6fde9fc52adb49530c6b2c25d8b3468ac986a097

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.3.0rc2-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.3.0rc2-cp39-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for qiskit-1.3.0rc2-cp39-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6b5668259d947e60be3c4ef04e2efae88aa574d5678b20403d95c8932739132a
MD5 56708f00eea2ce2b157209c88fb26e55
BLAKE2b-256 1efe5d56f8c5737205ff9b2b319a8a8b917b2e86336b7247eec4fd798355cde8

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit-1.3.0rc2-cp39-abi3-macosx_10_9_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