{"id":4737,"library":"qiskit","title":"Qiskit","description":"Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives. It provides tools for creating and manipulating quantum programs, and running them on prototype quantum devices on IBM Quantum Platform or on local simulators. The library follows a Semantic Versioning strategy, with major releases (containing breaking changes) approximately once a year, and minor releases every three months introducing new features and bug fixes.","status":"active","version":"2.3.1","language":"en","source_language":"en","source_url":"https://github.com/Qiskit/qiskit","tags":["quantum computing","sdk","ibm","quantum circuits","simulator","primitives"],"install":[{"cmd":"pip install qiskit","lang":"bash","label":"Core Qiskit SDK"},{"cmd":"pip install qiskit-aer matplotlib","lang":"bash","label":"For local simulation and visualization"},{"cmd":"pip install qiskit-ibm-runtime","lang":"bash","label":"For running on IBM Quantum hardware"}],"dependencies":[{"reason":"Required Python version.","package":"python","version":">=3.10","optional":false},{"reason":"Core dependency for numerical operations.","package":"numpy","version":">=1.21","optional":false},{"reason":"High-performance simulators for local execution, including noise models. Recommended for simulation workflows.","package":"qiskit-aer","optional":true},{"reason":"Allows submission of circuits and programs to IBM Quantum systems.","package":"qiskit-ibm-runtime","optional":true},{"reason":"Required for various visualization functions, e.g., plot_histogram.","package":"matplotlib","optional":true}],"imports":[{"symbol":"QuantumCircuit","correct":"from qiskit import QuantumCircuit"},{"note":"Qiskit 2.x and later uses the `qiskit.primitives` module for execution, replacing older simulator backends like `AerSimulator` or `BasicAer` for many common workflows. `AerSimulator` still exists in `qiskit_aer` for advanced simulation.","wrong":"from qiskit.providers.aer import StatevectorSimulator","symbol":"StatevectorSampler","correct":"from qiskit.primitives import StatevectorSampler"},{"note":"As of Qiskit 1.x, `qiskit_aer` is a separate package and its components are imported directly from `qiskit_aer`.","wrong":"from qiskit.providers.aer import AerSimulator","symbol":"AerSimulator","correct":"from qiskit_aer import AerSimulator"},{"symbol":"plot_histogram","correct":"from qiskit.visualization import plot_histogram"},{"note":"The legacy `IBMQ` module for managing IBM Quantum accounts was replaced by `QiskitRuntimeService` in `qiskit-ibm-runtime`.","wrong":"from qiskit import IBMQ","symbol":"QiskitRuntimeService","correct":"from qiskit_ibm_runtime import QiskitRuntimeService"}],"quickstart":{"code":"import matplotlib.pyplot as plt\nfrom qiskit import QuantumCircuit\nfrom qiskit.primitives import StatevectorSampler\n\n# Create a Bell state circuit\nqc = QuantumCircuit(2, 2) # 2 qubits, 2 classical bits\nqc.h(0) # Apply Hadamard gate to qubit 0\nqc.cx(0, 1) # Apply CNOT gate with control qubit 0 and target qubit 1\nqc.measure([0, 1], [0, 1]) # Measure both qubits into classical bits\n\n# Visualize the circuit\nprint(\"Circuit Diagram:\")\nprint(qc.draw(output='text'))\n\n# Run on a local simulator using the Sampler primitive\nsampler = StatevectorSampler()\njob = sampler.run([qc], shots=1024)\nresult = job.result()\n\n# Get measurement counts\ncounts = result[0].data.meas.get_counts()\nprint(\"\\nMeasurement Counts:\", counts)\n\n# Plot histogram of results\nplot_histogram(counts)\nplt.title(\"Bell State Measurement\")\nplt.show()","lang":"python","description":"This quickstart builds a Bell state (two entangled qubits), visualizes the circuit, runs it on a local `StatevectorSampler`, and then displays the measurement outcomes as a histogram. It demonstrates basic circuit creation, execution via primitives, and result visualization."},"warnings":[{"fix":"For upgrades from Qiskit 0.x to 1.x (or later major versions), create a new virtual environment and install Qiskit clean: `python -m venv .venv && source .venv/bin/activate && pip install qiskit`. Always review the official migration guides for specific version changes.","message":"Major breaking changes occurred between Qiskit 0.x and 1.x, and again between 1.x and 2.x. Upgrading from 0.x to 1.x cannot be done via `pip install -U qiskit` and requires a fresh installation, ideally in a new virtual environment, due to a new packaging structure.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Update code to use the new `qiskit.primitives` interface. Explicitly set the `shots` parameter in `Sampler.run()` or `Estimator.run()` calls to ensure consistent behavior, especially when migrating algorithms.","message":"The Qiskit Primitives API (Sampler and Estimator) underwent significant changes and is mandatory for Qiskit 2.x. Existing algorithm libraries built on Qiskit 1.x primitives will be incompatible. Additionally, the default `shots` parameter changed (e.g., from implicit unlimited to 10000), which can drastically alter algorithm behavior and reproducibility if not explicitly set.","severity":"breaking","affected_versions":"1.x.x to 2.x.x"},{"fix":"For pulse-level control, consider using Qiskit 1.x (which had bug-fix support until Sept 2024 and security support until March 2025) or exploring direct access to fractional gates on newer IBM Quantum QPUs. There is no direct migration path for `qiskit.pulse` functionality in Qiskit 2.x.","message":"The `qiskit.pulse` module, which provided pulse-level control, was removed in Qiskit 2.0.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Replace `circuit.duration` with `circuit.estimate_duration()`.","message":"The `QuantumCircuit.duration` attribute is deprecated in Qiskit 2.x and is recommended to be replaced by `QuantumCircuit.estimate_duration()` due to evolving complexities in classical control flow.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Refactor conditional logic to use `circuit.if_test` (as a context manager) or explicitly construct `IfElseOp` instances. Avoid direct use of `Instruction.condition`.","message":"Legacy `c_if` conditions on individual instructions have been removed in Qiskit 2.0. Classical conditions must now be expressed using `IfElseOp` or the `if_test` context manager.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure NumPy is updated to at least version `1.21`: `pip install --upgrade numpy`.","message":"The minimum required NumPy version was bumped to `1.21` in Qiskit 2.3.1. Users with older NumPy installations might encounter compatibility issues.","severity":"gotcha","affected_versions":">=2.3.1"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}