qiskit-circuit-utils
qiskit-circuit-utils is a collection of reusable circuit-building utilities for Qiskit, providing concise implementations of common quantum states, measurements, transformations, operations, and protocols.
The library is designed to complement Qiskit's QuantumCircuit API rather than replace it. Functions operate directly on a supplied circuit, making them easy to combine with standard Qiskit operations while keeping higher-level circuit construction readable.
Installation
Install from PyPI:
pip install qiskit-circuit-utils
Requirements:
- Python 3.11 or later
- Qiskit 2.0 or later
- NumPy 2.0 or later
Quick Start
Modules are intended to be imported by functionality:
from qiskit import QuantumCircuit
from qiskit_circuit_utils import preparation as prep
circuit = QuantumCircuit(3)
prep.ghz_state(circuit, [0, 1, 2])
print(circuit)
This modifies circuit in place by preparing its three qubits in a GHZ state.
Utilities can be combined freely with standard Qiskit operations:
from qiskit import QuantumCircuit
from qiskit_circuit_utils import measurement, preparation
circuit = QuantumCircuit(2, 2)
preparation.bell_state(circuit, [0, 1])
measurement.x(circuit, 0, 0)
measurement.z(circuit, 1, 1)
Features
The public API is organized into modules according to functionality.
preparation
See the full preparation API reference.
State-preparation utilities, including:
- Bell states
- GHZ and W states
- Computational basis states
|+>and|->states- Uniform superpositions
- Arbitrary statevectors
- Product states
- Random pure states
- Pauli X, Y, and Z eigenstates
- Single-qubit states specified by Bloch-sphere angles
from qiskit import QuantumCircuit
from qiskit_circuit_utils import preparation as prep
circuit = QuantumCircuit(2)
prep.bell_state(circuit, [0, 1], state="psi+")
measurement
See the full measurement API reference.
Measurement utilities for:
- X, Y, and Z bases
- Pauli-basis selection
- Bell-basis measurement
- Multi-qubit measurement
- Explicit qubit/classical-bit measurement pairs
from qiskit import QuantumCircuit
from qiskit_circuit_utils import measurement
circuit = QuantumCircuit(2, 2)
measurement.x(circuit, 0, 0)
measurement.y(circuit, 1, 1)
correction
See the full correction API reference.
Classically controlled correction operations, including:
- Conditional X corrections
- Conditional Z corrections
- Pauli X/Z corrections
- Corresponding multi-qubit operations
These utilities are useful when constructing protocols involving measurement-dependent corrections.
entanglement
See the full entanglement API reference.
Higher-level entanglement and communication protocols, including:
- Entanglement swapping
- Quantum teleportation
- GHZ-style entanglement distribution and extension
- Qubit connection and disconnection
- State transfer
- Superdense coding
from qiskit import QuantumCircuit
from qiskit_circuit_utils import entanglement
circuit = QuantumCircuit(3, 2)
entanglement.teleport(
circuit,
[0, 1, 2],
[0, 1],
)
operation
See the full operation API reference.
General circuit operations not specific to state preparation, measurement, or protocols.
Currently includes multi-qubit order reversal using SWAP gates:
from qiskit import QuantumCircuit
from qiskit_circuit_utils import operation
circuit = QuantumCircuit(4)
operation.reverse(circuit, [0, 1, 2, 3])
transform
See the full transform API reference.
Quantum circuit transformations, including:
- Quantum Fourier transform (QFT)
- Inverse quantum Fourier transform
Both transformations optionally include the final qubit-order reversal.
from qiskit import QuantumCircuit
from qiskit_circuit_utils import transform
circuit = QuantumCircuit(4)
transform.qft(circuit, [0, 1, 2, 3])
transform.inverse_qft(circuit, [0, 1, 2, 3])
Library Conventions
Circuits are modified in place
Public functions accept a QuantumCircuit as their first argument, modify that circuit directly, and return None.
prep.bell_state(circuit, [0, 1])
The library does not provide an alternative circuit class or wrapper around QuantumCircuit.
Qubits and classical bits
Utilities support Qiskit bit objects and integer bit specifiers where applicable, allowing calls such as:
prep.ghz_state(circuit, [0, 1, 2])
as well as calls using qubits obtained directly from a circuit or register.
Module-oriented imports
The recommended import style is:
from qiskit_circuit_utils import preparation as prep
prep.bell_state(circuit, [0, 1])
prep.ghz_state(circuit, [0, 1, 2])
rather than importing individual functions directly:
from qiskit_circuit_utils.preparation import bell_state
Module-oriented imports preserve the context of utility names and reduce the possibility of naming conflicts as multiple parts of the library are used together.
Examples
Runnable examples are available in the examples/ directory:
deutsch_algorithm.py— Deutsch's algorithmquantum_phase_estimation.py— quantum phase estimationquantum_teleportation.py— quantum teleportation
The examples demonstrate how the library's utilities can be combined with Qiskit to construct complete quantum circuits.
Project History
This library grew from a collection of utility functions originally written while working through Hiu Yung Wong's Introduction to Quantum Computing.
It has since been developed into a general-purpose package for reusable Qiskit circuit construction.
License
This project is distributed under the ['MIT license'][https://github.com/1Aiden-K/qiskit-circuit-utils/blob/main/LICENSE].
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qiskit_circuit_utils-1.0.0.tar.gz.
File metadata
- Download URL: qiskit_circuit_utils-1.0.0.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e29487aa06dd642060970f04a71cb4d4e405cb1af477530bf0e9c2dde5f16997
|
|
| MD5 |
ddb4be54b94a3b95bc3011eaaf50c5a2
|
|
| BLAKE2b-256 |
2b906138b6a42d32b5ef297d71b7110b3ec5fe0fa68bb426a229f8e3ce771177
|
Provenance
The following attestation bundles were made for qiskit_circuit_utils-1.0.0.tar.gz:
Publisher:
release.yml on 1Aiden-K/qiskit-circuit-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qiskit_circuit_utils-1.0.0.tar.gz -
Subject digest:
e29487aa06dd642060970f04a71cb4d4e405cb1af477530bf0e9c2dde5f16997 - Sigstore transparency entry: 2642777835
- Sigstore integration time:
-
Permalink:
1Aiden-K/qiskit-circuit-utils@9cdb8d8f66091829b87807f1842cdd4ec61a97c4 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/1Aiden-K
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9cdb8d8f66091829b87807f1842cdd4ec61a97c4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file qiskit_circuit_utils-1.0.0-py3-none-any.whl.
File metadata
- Download URL: qiskit_circuit_utils-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b56ae747cd9c47fd2074eae591d418ea4fb7b5d41222839725c63285e5da455b
|
|
| MD5 |
9aab52ba1c109c70c8370fe5747328d8
|
|
| BLAKE2b-256 |
c1156d25000a46b72ba0a0aceab3e3c81a6636462d54e058cbb927a555b863a1
|
Provenance
The following attestation bundles were made for qiskit_circuit_utils-1.0.0-py3-none-any.whl:
Publisher:
release.yml on 1Aiden-K/qiskit-circuit-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qiskit_circuit_utils-1.0.0-py3-none-any.whl -
Subject digest:
b56ae747cd9c47fd2074eae591d418ea4fb7b5d41222839725c63285e5da455b - Sigstore transparency entry: 2642778151
- Sigstore integration time:
-
Permalink:
1Aiden-K/qiskit-circuit-utils@9cdb8d8f66091829b87807f1842cdd4ec61a97c4 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/1Aiden-K
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9cdb8d8f66091829b87807f1842cdd4ec61a97c4 -
Trigger Event:
release
-
Statement type: