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.

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

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

quad-0.1.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file quad-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: quad-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for quad-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11bbd1991f2f410443d4f931ec27829fd86ef10f6f945eab09b9f5b2973419f6
MD5 17a5e330fa048e14b15d64ea57238970
BLAKE2b-256 6c2b5c28e8ddef2e24f15f3cf00f165e39e9e8b2d3f11e15f612aa36413c7ab7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page