-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Description
MWE, need https://github.com/QuantumBFS/YaoTargetQASM.jl for the syntax, on 1.6.1
using OpenQASM
using YaoTargetQASM
using YaoCompiler
using YaoCompiler.Intrinsics
using CompilerPluginTools
qasm"""
OPENQASM 2.0;
gate cx c,t { CX c,t; }
gate u1(lambda) q { U(0,0,lambda) q; }
gate t a { u1(pi/4) a; }
gate h a { u2(0,pi) a; }
gate tdg a { u1(-pi/4) a; }
gate ccx a,b,c
{
h c;
cx b,c; tdg c;
cx a,c; t c;
cx b,c; tdg c;
cx a,c; t b; t c; h c;
cx a,b; t a; tdg b;
cx a,b;
}
gate majority a,b,c
{
cx c,b;
cx c,a;
ccx a,b,c;
}
"""
ast = code_qasm(typeof(majority()))
This gives you the following
julia> ast = code_qasm(typeof(majority()))
OPENQASM 2.0;
qreg qreg_1[3];
CX qreg_1[2], qreg_1[1];
CX qreg_1[2], qreg_1[0];
h qreg_1[2];
CX qreg_1[1], qreg_1[2];
tdg qreg_1[2];
CX qreg_1[0], qreg_1[2];
t qreg_1[2];
CX qreg_1[1], qreg_1[2];
tdg qreg_1[2];
CX qreg_1[0], qreg_1[2];
t qreg_1[1];
t qreg_1[2];
h qreg_1[2];
CX qreg_1[0], qreg_1[1];
t qreg_1[0];
tdg qreg_1[1];
CX qreg_1[0], qreg_1[1];
but h
and t
should be inlined instead of invoke
, this seems to only happen when ccx
is called inside another function, and for ccx
itself it is fine
julia> code_qasm(typeof(ccx()))
OPENQASM 2.0;
qreg qreg_1[3];
h qreg_1[2];
CX qreg_1[1], qreg_1[2];
rz(0) qreg_1[2];
ry(0) qreg_1[2];
rz(-0.7853981633974483) qreg_1[2];
CX qreg_1[0], qreg_1[2];
rz(0) qreg_1[2];
ry(0) qreg_1[2];
rz(0.7853981633974483) qreg_1[2];
CX qreg_1[1], qreg_1[2];
rz(0) qreg_1[2];
ry(0) qreg_1[2];
rz(-0.7853981633974483) qreg_1[2];
CX qreg_1[0], qreg_1[2];
rz(0) qreg_1[1];
ry(0) qreg_1[1];
rz(0.7853981633974483) qreg_1[1];
rz(0) qreg_1[2];
ry(0) qreg_1[2];
rz(0.7853981633974483) qreg_1[2];
h qreg_1[2];
CX qreg_1[0], qreg_1[1];
rz(0) qreg_1[0];
ry(0) qreg_1[0];
rz(0.7853981633974483) qreg_1[0];
rz(0) qreg_1[1];
ry(0) qreg_1[1];
rz(-0.7853981633974483) qreg_1[1];
CX qreg_1[0], qreg_1[1];
the CodeInfo
can be obtained via
code_typed(Intrinsics.apply, (AnyReg, typeof(majority())); interp=YaoInterpreter())
I think need some help from you @vchuravy
Metadata
Metadata
Assignees
Labels
No labels