Giter VIP home page Giter VIP logo

qip's Introduction

QIP

QIP is a python library for qubit simulation meant to feel like tensorflow or other graph pipeline libraries. Users may define a set a qubits and then perform operations on them by constructing objects taking them as input. Since the library currently doesn't use a GPU no session object is required and the graphs may be easily reused.

Example usage for CSwap inner product:

# Define 11 qubits
q1 = Qubit(n=1)
q2 = Qubit(n=5)
q3 = Qubit(n=5)

# Perform a Hadamard transform on qubit 1
h1 = H(q1)

# Perform a CSwap operation on all 11 bits using the output
# of H(q1) as the control bit. Notice that Swap is its own
# operation and CSwap is constructed by applying C(...) to 
# the swap operation.
c1, c2, c3 = C(Swap)(h1, q2, q3)

# Finally perform another Hadamard transform on qubit 1
m1 = H(c1)

At this point we have constructed an object m1 which is the output of the entire graph of operations. To run we must feed in initial values:

state1 = [1.0, 0.0]

# Make two initial states for the pair of 5 qubit entries
state2 = numpy.zeros((32,))
state2[0] = 1.0

state3 = numpy.zeros((32,))
state3[1] = 1.0

# Feed the initial states for each set of qubits
o, _ = m1.run(feed={q1:state1, q2: state2, q3: state3})

o is a vector of size 2048 giving the complete state for each possible |q1, q2, q3>

For more examples see the wiki or the examples directory! QIP supports many useful features such as type annotations, wrapping functions to become first class operators, and abstract backends and graph accumulators!

Installation

Installation via pip with pip install qip.

To install manually from the repo you need to build cython files, this can be done by installing normal requirements plus pip install cython, then exporting an enivironment variable to enable compilation export CYTHON=1. Then pip install . in the repo directory will compile and install. (This process is being improved). The pip version may be behind the github, but it more likely to be stable and bug-free.

qip's People

Contributors

renmusxd avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

qip's Issues

Streamline installation process

Right now the use of environment variables to enable CYTHON and OPENMP support is a bit burdensome, streamlining this would be a nice addition.

Make a distributed backend

Should be able to split state across large number of computers.

See parallelism branch for development.

Double check and update documentation

There have been some growing pains and docs may have been missed. Particularly concerned about type-annotation/doc mismatches but out-of-date api calls may also be present.

Jupyter notebook integration

Looking for ideas for streamlines notebook integration.
Examples:

  • Add an html/latex representation for qubit objects when displayed to give more context than is really useful in the repr calls.
  • Pipeline widget showing progress bar.
  • ...

Cython must be installed before installing QIP with pip

In order to get the cythonize used in setup.py command we need Cython to be installed. This means the process isn't as streamlined as pip install qip.

There may be a way to do something like what was done for numpy to get around this. This seems to be a common problem and solutions are often very difficult to understand or are very hacky and hard to reimplement.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.