Skip to content
Python Framework for Quantum Computer
Branch: master
Clone or download
Latest commit 8fae657 Apr 23, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci add sympy to optional-requirements Jan 27, 2019
blueqat
doc Complete the first version of English document with Japanese tarnslat… Dec 19, 2018
examples VQE modifications Dec 2, 2018
tests [sympy-backend] ignore global phase of first diagonal element Apr 22, 2019
tutorial update 15,21 Mar 18, 2019
.gitignore U Gate. Jan 28, 2019
.python-version add 2tutorials Jan 17, 2019
.readthedocs.yml Add build config for Read the Docs to use Python 3.6 to prevent error… Dec 20, 2018
LICENSE
MDR_Blueqat_color.png update Oct 11, 2018
README.rst
dev-requirements.txt Update dev-requirements qiskit version Jan 28, 2019
optional-requirements.txt update qiskit Jan 31, 2019
requirements.txt
setup.py Change URL, Author in setup.py Mar 25, 2019

README.rst

Blueqat

blueqat

A quantum computing SDK

Version

Build info

https://circleci.com/gh/Blueqat/Blueqat.svg?style=svg

Tutorial

https://github.com/mdrft/Blueqat/tree/master/tutorial

Install

git clone https://github.com/Blueqat/Blueqat
cd Blueqat
pip3 install -e .

or

pip3 install blueqat

Circuit

from blueqat import Circuit
import math

#number of qubit is not specified
c = Circuit()

#if you want to specified the number of qubit
c = Circuit(3) #3qubits

Method Chain

# write as chain
Circuit().h[0].x[0].z[0]

# write in separately
c = Circuit().h[0]
c.x[0].z[0]

Slice

Circuit().z[1:3] # Zgate on 1,2
Circuit().x[:3] # Xgate on (0, 1, 2)
Circuit().h[:] # Hgate on all qubits
Circuit().x[1, 2] # 1qubit gate with comma

Rotation Gate

Circuit().rz(math.pi / 4)[0]

Measurement

Circuit().m[0]

Run()

Circuit().h[0].cx[0,1].run()

Run(shots=n)

c = Circuit().h[0].cx[0,1].m[:]
c.run(shots=100) # => Counter({'00': 48, '11': 52}) (random value.)

Hamiltonian

from blueqat.pauli import *

hamiltonian1 = (1.23 * Z[0] + 4.56 * X[1] * Z[2]) ** 2
hamiltonian2 = (2.46 * Y[0] + 5.55 * Z[1] * X[2] * X[1]) ** 2
hamiltonian = hamiltonian1 + hamiltonian2
print(hamiltonian)

simplify the hamiltonian

hamiltonian = hamiltonian.simplify()
print(hamiltonian)

VQE

from blueqat import vqe
from blueqat.pauli import qubo_bit as q

hamiltonian = -3*q(0)-3*q(1)-3*q(2)-3*q(3)-3*q(4)+2*q(0)*q(1)+2*q(0)*q(2)+2*q(0)*q(3)+2*q(0)*q(4)+2*q(1)*q(2)+2*q(1)*q(3)+2*q(1)*q(4)+2*q(2)*q(3)+2*q(2)*q(4)+2*q(3)*q(4)
step = 2

result = vqe.Vqe(vqe.QaoaAnsatz(hamiltonian, step)).run()
print(result.most_common(12))

If you want to create an ising model hamiltonian use Z(x) instead of q(x) in the equation

hamiltonian = Z(0)-3*Z(1)+2*Z(0)*Z(1)+2*Z(0)*Z(2)

Blueqat to Qiskit

qiskit.register(APItoken)
sampler = blueqat.vqe.get_qiskit_sampler(backend="backend name")
result = blueqat.vqe.Vqe(QaoaAnsatz(...), sampler=sampler).run(verbose=True)

Blueqat to QASM

Circuit.to_qasm()

#OPENQASM 2.0;
#include "qelib1.inc";
#qreg q[1];
#creg c[1];
#h q[0];

Example

2-qubit Grover

from blueqat import Circuit
c = Circuit().h[:2].cz[0,1].h[:].x[:].cz[0,1].x[:].h[:].m[:]
print(c.run(shots=1))

Maxcut QAOA

from blueqat import vqe, pauli
edges = [(0, 1), (1, 2), (2, 3), (3, 0), (1, 3), (0, 2), (4, 0), (4, 3)]
ansatz = vqe.QaoaAnsatz(sum([pauli.Z(i) * pauli.Z(j) for i, j in edges]), 1)
result = vqe.Vqe(ansatz).run()
print(
"""   {4}
  / \\
 {0}---{3}
 | x |
 {1}---{2}""".format(*result.most_common()[0][0]))

Optimization(recommended)

from blueqat.opt import Opt
c = Opt().add([[1,1],[1,1]]).add("(q0+q1)^2",N=2)

#qaoa
print(c.qaoa().most_common(5))
#=>(((0, 0), 0.7639901896866), ((1, 0), 0.10321404014639714), ((0, 1), 0.10321404014639707), ((1, 1), 0.029581730020605202))

#annealing
print(c.run())
[0, 0]

Annealing-2 (old)

from blueqat import opt
a = opt.opt()
a.qubo = opt.sel(3,1) #creating QUBO matrix
result = a.sa(shots=100,sampler="fast")
opt.counter(result)

Counter({'010': 29, '100': 34, '001': 37})

Document

https://blueqat.readthedocs.io/en/latest/

Author

Takumi Kato (MDR), Yuichiro Minato (MDR), Yuma Murata (D Slit Technologies), Satoshi Takezawa (TerraSky)

Disclaimer

Copyright 2019 The Blueqat Developers.

You can’t perform that action at this time.