Skip to main content

A database for storing and querying quantum state vectors.

Project description

QUAD: Quantum State Database

Graduate research project for CMSC 33550 (Introduction to Databases) at University of Chicago.


$ pip3 uninstall cirq  # Fix possibly conflicting packages
$ pip3 install quad  # Install


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(

# Create locality sensitive collection of vectors
collection = quad.AsymmetricLocalCollection(
    prng=np.random.RandomState(seed=5),  # Ensure consistent across runs
for vid in store:

# 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,
print('Possibly close vids:', close_vids)
assert close_vids == set(range(40, 50))


$ git clone  # Clone repo
$ cd quantum-state-database
$ pip install -e .[dev]  # Install dev requirements
$ python quad/benchmark/  # Generate test state vector data
$ pytest quad/benchmark/  # Run all benchmarks

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for quad, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size quad-0.1.0-py3-none-any.whl (19.4 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page