A quantum computing library using qiskit
Project description
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.
Instalation
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.
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 Distributions
Built Distribution
File details
Details for the file qclib-0.1.12-py3-none-any.whl
.
File metadata
- Download URL: qclib-0.1.12-py3-none-any.whl
- Upload date:
- Size: 139.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86428dac3a840470409ce61ad28beda7f1253c7d6938894ad0c55ec6ffd8e402 |
|
MD5 | 246e43b90cf03fa5747baa4c3c8d537c |
|
BLAKE2b-256 | e4e47ed47698c3d5256c8bc9f62be194d2429a3a41c92afc753fde59b6f84a4d |