2
$\begingroup$

I would like to see the compiled circuit as executed on a hardware. Nominally, this sequence of commands should return the QASM circuit in the variable ran_qc, but it is a Null pointer. Does anyone know how to make it work?

I was notified via this ticket that it should be fixed, but I do not see any improvement on my end.

I'm using qiskit.version'0.6.1' and connected to IBMQX4.

jobRes=job.result()
print('ran_qc get_names()=',jobRes.get_names())
assert len( jobRes.get_names()) ==1
circuit_name = jobRes.get_names()[0]
print('ran_qc name=',circuit_name)
ran_qc=jobRes.get_ran_qasm(circuit_name)
print(ran_qc)
$\endgroup$
2
$\begingroup$

You need to extract the compiled qasm from a qobj object. You can create this by compiling

from qiskit import compile
qobj = compile(qc,backend,shots=shots)

If you want to create a batch job, where you send many circuits in at once, you can replace the single circuit qc with a list of circuits.

Information about the circuits, the backend on which they'll run, and how they've been compiled, can then be found by querying the qobj.

Perhaps the best was is to use qobj.as_dict(), which returns a dictionary containing the information. In Qiskit 0.7.0 (which will be the stable version as of end of Dec 2018), you can get the information you want using

qobj.as_dict()['experiments'][index]['header']['compiled_circuit_qasm']

Actually running the job defined by the qobj can be done with

job = backend.run(qobj)
$\endgroup$
  • $\begingroup$ Thanks James, I know I can compile my qc on my laptop w/ compile(qc,backend,shots=shots, seed=123) but a) this compilation depends also on the seed - so there is no unique answer b) I do not know what happens after API at IBM receives my API request job= execute(qc, backend, shots=1024,seed=123) Do they use the same pseduo-random generator, the same quantum circuit compiler as on my laptop? I want to know what circuit was executed when programing IBMQX4 when I made the API call, not what it could be. This functionality was working for ver 0.5.1, it is somehow disabled for 0.6.1. $\endgroup$ – Jan Balewski Dec 16 '18 at 5:43
  • $\begingroup$ [cont.] I'll wait for 0.7.0 to see how it works. Thanks Jan $\endgroup$ – Jan Balewski Dec 16 '18 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.