Giter Club home page Giter Club logo

kebab's Introduction

Kebab

Kebab is a quantum computation framework for Julia.Kebab aims to realize quantum algorithm simulation in different level(eg.hardware level/software level/...) under different computation model and provide useful support for experiments.

This will allow users to play with a simulated quantum computer with only basic hardware APIs.

current functions

  • Quantum Circuit quantum circuit is basic structure to use this framework.

  • Quantum Fourier Transformation QFT is based on quantum circuit

  • Adiabatic Computation Adiabatic Computation Module is realized by add adiabatic evolution gates

  • Cooling the cooling method comes from the doi:10.103

Simple User Guide

To use this package, use Pkg.clone(https://github.com/Roger-luo/Kebab.git)

or download the source codes from github.

Construct a circuit

a circuit is constructed by Circuit:

you can construct an empty circuit:

circuit = Circuit()

to add gates, use the method addgate!

the addgate! method allows following way to add a quantum gate or a module to a specific place in the circuit.

# for single qubit gates(like Hadamard)
# circuit : the circuit object
# gate : gate object you want to insert
# id   : the id of the qubit you want to add this gate to
addgate!(circuit,gate,id)

# for example
# |a> ----[H]----
# |b> -----------
# |c> -----------
# let's add a Hadamard gate to the first qubit in this three-qubit circuit

# first creat your circuit
c = Circuit()
addgate!(c,Hadamard,1)

to measure a circuit, simply use the measure method on the circuit you want to measure with the the circuit's input state

# measure the circuit:
# |a> ----[H]----
# |b> -----------
# |c> -----------
# with input state:
# 1/2*sqrt(2)(|000>+|001>+|010>+...+|111>)

input_state = InitState(3)
circuit = Circcuit()
addgate!(circuit,Hadamard,1)
res_state = measure(circuit,input_state)

For Adiabatic Models

TruthTable(truthvalue,bitID)

use TruthTable to construct the cost function,for example a cost function define below

\begin{aligned}&h_c(z_1,z_2,z_3) = 1\quad \text{if there is a 1 among } (z_1,z_2,z_3)\\&h_c(z_1,z_2,z_3) = 0\quad \text{if not}\end{aligned}

then the truth table of this cost function is

bits value truth value
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 0

so the truth table construct as following,the truthvalue contains the truth value as a number and the bitID contains the ID of bits in this truth table

TruthTable(0b01101000,[1,2,3])

for multi-thread calculation,use the blas_set_num_threads method

One example for cooling-assist computation

using Kebab
using PyPlot

function CoolingAssit(
    Hs::AdiaSystem,
    bitnum::Real;
    dt = 1e-2
    )
    #init variables
    const evotime = Hs.maxtime
    state = convert(Array{Complex,1},[1/sqrt(2^bitnum) for i=1:2^bitnum])

    eigens = TimeEvoModule!(state,Hs,1/3;dt=dt)

    #cooling module
    gamma,t = CoolingPara(Hs)
    print("enter cooling module 1\n")
    CoolingModule!(state,Hs,gamma,t;n=5)
    print("finish cooling\n")

    eigens = TimeEvoModule!(state,Hs,1/3;dt=dt)

    #cooling module
    gamma,t = CoolingPara(Hs)
    print("enter cooling module 2\n")
    CoolingModule!(state,Hs,gamma,t;n=5)
    print("finish cooling\n")

    eigens = [eigens TimeEvoModule!(state,Hs,1/3;dt=dt)]
    
    success_prob = abs2([x==findmin(diag(Hs.HP))[2]?1:0 for x=1:2^bitnum])
    return eigens,state,success_prob[1]
end

H = AdiaSystem([TruthTable(0b1001,[1,2])],2,1e3)
eigen,state,p = CoolingAssit(H,2)

print("pass\n")

figure(1)
for i=1:size(eigen)[1]
    plot(real(eigen[i,:]))
end

show()

kebab's People

Contributors

roger-luo avatar

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.