Skip to main content

Quantum computing library (qclib)

Qclib is a quantum computing library implemented using qiskit.

The focus of qclib is on preparing quantum states, but it is not limited to that.

Installation

The easiest way of installing qclib is by using pip:

pip install qclib

Initializing your first quantum state with qclib

Now that qclib is installed, you can start building quantum circuits to prepare quantum states. Here is a basic example:

$ python
import numpy as np
from qiskit import transpile
from qiskit_aer import AerSimulator
from qclib.state_preparation import LowRankInitialize

# Generate 3-qubit random input state vector
n = 3
rnd = np.random.RandomState(42)
input_vector = rnd.rand(2 ** n) + rnd.rand(2 ** n) * 1j
input_vector = input_vector / np.linalg.norm(input_vector)

# Build a quantum circuit to initialize the input vector
circuit = LowRankInitialize(input_vector).definition

# Construct an ideal simulator
backend = AerSimulator()

# Tests whether the produced state vector is equal to the input vector.
t_circuit = transpile(circuit, backend)
t_circuit.save_statevector()
state_vector = backend.run(t_circuit).result().get_statevector()
print('Equal:', np.allclose(state_vector, input_vector))
# Equal: True

Comparing algorithms for quantum state preparation

The following table shows the depth, number of qubits, and CNOTs of circuits produced by different state preparation methods for the same random 15-qubit state.

method lib qubits cnots depth
low-rank qclib 15 30998 53643
svd qclib 15 38814 71580
ucg qclib 15 32752 65505
isometry qiskit 15 32752 65505
multiplexor qiskit 15 65504 131025
bdsp qclib 1151 72320 1603
dcsp qclib 32767 262016 899

You can reproduce the results here.

Authors

The first version of qclib was developed at Centro de Informática - UFPE. Qclib is an active project, and other people have contributed.

If you are doing research using qclib, please cite our project. We use a CITATION.cff file, so you can easily copy the citation information from the repository landing page.

License

qclib is free and open source, released under the Apache License, Version 2.0.

Metadata

Release files for qclib 0.1.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for qclib 0.1.15
File Interpreter ABI Platform
qclib-0.1.15-py3-none-any.whl Python 3 none any Details

Release files / qclib-0.1.15-py3-none-any.whl

Download URL qclib-0.1.15-py3-none-any.whl
Size 162.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
773b41cefc7154d5466f55777c71ad5d3813e117f7f4637d957b982c48e4922a
BLAKE2b-256 checksum
How to use checksums
38eac69248ea6b6e50e68c805d585f5f752bdf378b606f2b75e904a87cb1eeb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.18

Security for qclib 0.1.15

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page