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
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()