Skip to content

Instantly share code, notes, and snippets.

@quantumjim
Last active February 5, 2019 18:39
Show Gist options
  • Save quantumjim/0efd0c49847b6f212d614bdc78b488f2 to your computer and use it in GitHub Desktop.
Save quantumjim/0efd0c49847b6f212d614bdc78b488f2 to your computer and use it in GitHub Desktop.
Some QASMs
# I ran the following code
device = 'ibmqx4'
print(engine.get_qasm("script"))
qobj = engine.compile(["script"], backend=device)
print(engine.get_compiled_qasm(qobj,"script"))
executedJob = engine.execute(["script"], backend=device, shots=shots, max_credits = 5, wait=2, timeout=600, silent=False)
# obviously there was a whole lot of stuff before it too, setting up the code
# What follows in this gist are the QASMs that were printed in the above commands. Alternatively, you can find them represented in the QX composer at https://quantumexperience.ng.bluemix.net/qx/community/question?questionId=3e13dc12ce5c50eeb2fbf23b28057851
# The first print command gives the following (uncompiled) QASM
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
creg c[5];
u3(-0.585739691098018,-1.570796326794897,1.570796326794897) q[0];
u3(-0.865866676582381,-1.570796326794897,1.570796326794897) q[1];
u3(-0.477274429657032,-1.570796326794897,1.570796326794897) q[2];
u3(-1.722716052919321,-1.570796326794897,1.570796326794897) q[3];
u3(-3.005959723765326,-1.570796326794897,1.570796326794897) q[4];
cx q[2],q[0];
u3(0.893030943848282,-1.570796326794897,1.570796326794897) q[2];
cx q[2],q[0];
cx q[3],q[4];
u3(1.285412377335352,-1.570796326794897,1.570796326794897) q[3];
cx q[3],q[4];
cx q[2],q[0];
u3(-0.948069930976954,-1.570796326794897,1.570796326794897) q[2];
cx q[2],q[0];
cx q[3],q[4];
u3(-1.248214151362281,-1.570796326794897,1.570796326794897) q[3];
cx q[3],q[4];
u3(0.585739691098018,-1.570796326794897,1.570796326794897) q[0];
u3(0.865866676582381,-1.570796326794897,1.570796326794897) q[1];
u3(0.477274429657032,-1.570796326794897,1.570796326794897) q[2];
u3(1.722716052919321,-1.570796326794897,1.570796326794897) q[3];
u3(3.005959723765326,-1.570796326794897,1.570796326794897) q[4];
cx q[1],q[0];
u3(1.272085806649446,-1.570796326794897,1.570796326794897) q[1];
cx q[1],q[0];
cx q[2],q[4];
u3(1.422049851975963,-1.570796326794897,1.570796326794897) q[2];
cx q[2],q[4];
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];
measure q[3] -> c[3];
measure q[4] -> c[4];
# The second gives me the following (compiled) QASM
OPENQASM 2.0;
include "qelib1.inc";
qreg q[5];
creg c[5];
u3(-3.005959723765326,-1.570796326794897,1.570796326794897) q[4];
u3(-1.722716052919321,-1.570796326794897,1.570796326794897) q[3];
cx q[3],q[4];
u3(1.285412377335352,-1.570796326794897,1.570796326794897) q[3];
cx q[3],q[4];
cx q[3],q[4];
u3(-1.248214151362281,-1.570796326794897,1.570796326794897) q[3];
cx q[3],q[4];
u3(1.722716052919321,-1.570796326794897,1.570796326794897) q[3];
measure q[3] -> c[3];
u3(3.005959723765326,-1.570796326794897,1.570796326794897) q[4];
u3(-0.477274429657032,-1.570796326794897,1.570796326794897) q[2];
u3(-0.865866676582381,-1.570796326794897,1.570796326794897) q[1];
u3(0.865866676582381,-1.570796326794897,1.570796326794897) q[1];
u3(-0.585739691098018,-1.570796326794897,1.570796326794897) q[0];
cx q[2],q[0];
u3(0.893030943848282,-1.570796326794897,1.570796326794897) q[2];
cx q[2],q[0];
cx q[2],q[0];
u3(-0.948069930976954,-1.570796326794897,1.570796326794897) q[2];
cx q[2],q[0];
u3(0.585739691098018,-1.570796326794897,1.570796326794897) q[0];
cx q[1],q[0];
u3(1.272085806649446,-1.570796326794897,1.570796326794897) q[1];
cx q[1],q[0];
measure q[0] -> c[0];
measure q[1] -> c[1];
u3(0.477274429657032,-1.570796326794897,1.570796326794897) q[2];
cx q[2],q[4];
u3(1.422049851975963,-1.570796326794897,1.570796326794897) q[2];
cx q[2],q[4];
measure q[2] -> c[2];
measure q[4] -> c[4];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment