-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
qasm to blocks implementation #13
base: main
Are you sure you want to change the base?
Conversation
@Roger-luo I have written the initial macro. Thanks for you help in the issue I finally have some clarity. Also for the single qubit unitary gates I have used the implementation here YaoBlocksQobj(QuantumBFS/YaoBlocksQobj.jl#16) |
So this implementation is quite brute-force, it generates the right code, but not the correct implementation, and it doesn't support user defined To be more detailed, I'm expecting the following code to work for toplevel QASM code OPENQASM 2.0;
qreg qreg_1[1];
rz(0) qreg_1;
ry(0) qreg_1;
rz(1.5707963267948966) qreg_1; should generate function main(n)
circuit = chain(n)
push!(circuit, put(1=>rz(0)))
push!(circuit, put(1=>ry(0)))
push!(circuit, put(1=>rz(1.5707963267948966)))
return circuit
end and for gate routine gate rx(theta) qreg_1 {
rz(theta) qreg_1;
ry(-1.5707963267948966) qreg_1;
rz(1.5707963267948966) qreg_1;
} should generate function rx(n, theta)
circuit = chain(n)
push!(circuit, rz(n, theta))
push!(circuit, ry(n, -1.5707963267948966))
push!(circuit, rz(n, 1.5707963267948966))
return circuit
end this is kinda just a standard transform between two different ASTs, which should apply for almost any other languages. You only implemented what we called the intrinsics at the moment in this PR. And since QASM allows one to define multiple registers, you will need to fuse them together and remap the qubit address in the global register address like what I do here: https://github.com/QuantumBFS/YaoTargetQASM.jl/blob/master/src/frontend.jl#L21 but since you don't need to handle control flows and only the YaoBlocks compatible part this should be simpler than mine implementation over there. |
PS. you can decide the syntax of total number of qubits rx(theta) = @lambda(n -> rx(n, theta)) when you generate the function, consider https://expronicon.rogerluo.dev/dev/ which may make your life easier |
Thanks for the review. I'll look into this. |
No description provided.