Quant-Team / qvm

simple quantum virtual machine
MIT License
6 stars 1 forks source link

Create intermediate Representation by QASM #7

Open sah4ez opened 5 years ago

sah4ez commented 5 years ago

Exist several specification of Quantum Assembly Languages, as example: https://github.com/Qiskit/openqasm https://github.com/rigetti/quil https://arxiv.org/pdf/1805.09607.pdf so, need create an intermediate representation of quantum language, which will loading from human-redable format to binary data and simulation or execute on real QPU.

sah4ez commented 5 years ago

As example, we can send to interpreter this command:

H 0
CNOT 0 1
MEASURE 0 1

this algorithm of Bell state.
So we should this commands load to some runtime, and apply this commands on register. First apply Hadamard gate on 0 register, Second apply C-NOT gate on 0 -> 1, And the last to measure state of qubits. After this we should have 0,0 or 1, 1 values for qubits.

sah4ez commented 5 years ago

Equivalent of command in prev comment in golang using register commands:

r := Register(2)
m := r.Apply(H(),1).Apply(CNOT(),2,1).Measure()
// m[0] = |0> -> m[1] = |0>
// or
// m[0] = |1> -> m[1] = |1>
sah4ez commented 5 years ago

Need create AST for Intermediate Representation (IR) and create a parser and a lexer for the each of implementations QASM, which will be parse source code in IR and execute on simulator or real QPU.