Code Monkey home page Code Monkey logo

koala's Introduction

Koala

Koala is a quantum circuit/state simulator based on PEPS tensor networks.

Installation

NumPy and TensorBackends are required. It is recommended to install Koala and TensorBackends in the editable (pip install -e) mode, as they are currently under development.

git clone https://github.com/cyclops-community/tensorbackends.git
pip install -e ./tensorbackends
git clone https://github.com/LinjianMa/koala.git
pip install -e ./koala

Parallelization is provided by Cyclops Tensor Framework, and is optional.

Testing

python -m unittest

Get Started

from koala import peps, Observable, Gate

# initialize a 2 by 3 state with peps approach and numpy backend
qstate = peps.computational_zeros(2, 3, backend='numpy')

# we also provide statevector approach and parallel backend
# statevector.computational_zeros(2, 3, backend='ctf')

# apply one gate or a list of gates
qstate.apply_gate(Gate('X', [], [0])) # (name, parameters, qubits)
qstate.apply_circuit([
    Gate('R', [0.42], [2]),
    Gate('CX', [], [1,4])
], threshold=None, maxrank=None)
# optional truncation threshold and rank for approximate simulation

# or apply arbitrary single site or local two-site operators
# qstate.apply_operator(np.array(...), [0])

# compute the amplitude, probability, and expectation value
qstate.amplitude([1,0,0,1,0,0])
qstate.probability([1,0,0,1,0,0])
observable = 1.5 * Observable.sum([
    Observable.Z(0),
    Observable.XY(3, 4) * 2
])
qstate.expectation(observable, use_cache=True) # optional caching

koala's People

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.