QUAD: Quantum State Database
Graduate research project for CMSC 33550 (Introduction to Databases) at University of Chicago.
Installation
$ pip3 uninstall cirq # Fix possibly conflicting packages
$ pip3 install quad # Install
Usage
import quad
dimension = 100
store = quad.VectorStore('path/to/vector/database') # Load or create vector database
# First time only: Add vectors to database
for i in range(10):
prng = np.random.RandomState(i)
base_vector = prng.normal(size=dimension)
for j in range(10):
# Generate any vectors
vector = base_vector + np.random.normal(scale=0.05, size=dimension)
info = {'any-data': ...}
vid = store.add(vector, info)
# Several hashes available: L2DistanceHash, MipsHash, StateVectorDistanceHash
h = quad.lsh.L2DistanceHash.from_random(
d=dimension,
r=2.5,
preproc_scale=1,
)
# Create locality sensitive collection of vectors
collection = quad.AsymmetricLocalCollection(
vector_store=store,
base_lsh=h,
meta_hash_size=10,
number_of_maps=10,
prng=np.random.RandomState(seed=5), # Ensure consistent across runs
)
for vid in store:
collection.add(vid)
# Query similar vectors:
prng = np.random.RandomState(4)
query_vector = prng.normal(size=dimension) # Some query vector
query_vid = store.add(query_vector, {'type': 'query'})
norm = 1#np.linalg.norm(query_vid)
close_vids = set(collection.iter_local_buckets(query_vid,
scale=1/norm))
print('Possibly close vids:', close_vids)
assert close_vids == set(range(40, 50))
Benchmarks
$ git clone https://github.com/cduck/quantum-state-database # Clone repo
$ cd quantum-state-database
$ pip install -e .[dev] # Install dev requirements
$ python quad/benchmark/benchmark_generate.py # Generate test state vector data
$ pytest quad/benchmark/ # Run all benchmarks
Metadata
Release files for quad 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| quad-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / quad-0.1.0-py3-none-any.whl
| Download URL | quad-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11bbd1991f2f410443d4f931ec27829fd86ef10f6f945eab09b9f5b2973419f6
|
|
BLAKE2b-256 checksum How to use checksums |
6c2b5c28e8ddef2e24f15f3cf00f165e39e9e8b2d3f11e15f612aa36413c7ab7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.0
|