项目作者: Renmusxd

项目描述 :
Quantum computing simulator with a tensorflow-like API
高级语言: Python
项目地址: git://github.com/Renmusxd/QIP.git
创建时间: 2017-09-25T02:54:08Z
项目社区:https://github.com/Renmusxd/QIP

开源协议:MIT License

下载


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:

  1. # Define 11 qubits
  2. q1 = Qubit(n=1)
  3. q2 = Qubit(n=5)
  4. q3 = Qubit(n=5)
  5. # Perform a Hadamard transform on qubit 1
  6. h1 = H(q1)
  7. # Perform a CSwap operation on all 11 bits using the output
  8. # of H(q1) as the control bit. Notice that Swap is its own
  9. # operation and CSwap is constructed by applying C(...) to
  10. # the swap operation.
  11. c1, c2, c3 = C(Swap)(h1, q2, q3)
  12. # Finally perform another Hadamard transform on qubit 1
  13. 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:

  1. state1 = [1.0, 0.0]
  2. # Make two initial states for the pair of 5 qubit entries
  3. state2 = numpy.zeros((32,))
  4. state2[0] = 1.0
  5. state3 = numpy.zeros((32,))
  6. state3[1] = 1.0
  7. # Feed the initial states for each set of qubits
  8. 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.