I am trying to run the QFT algorithm for n=5 (n number of qubits). The number of experiments that it generates is bigger than the one allowed by the IBM devices (i.e. 75). Therefore, I have tried to used the IBMQJobManager but this is not working as my result is not the counts but the density matrix obtain from the tomography process. Is it possible to make it work? I have made the following attempt (qft is a function that I have created that implements the QFT algorithm):


qst = tomo.state_tomography_circuits(qc, qr)
job = job_manager.run(qst, backend=device, name='foo',shots=8192)
statefit = tomo.StateTomographyFitter(job.results(), qst)
p, M, weights = statefit._fitter_data(True, 0.5)
M_dg = np.conj(M).T
linear_inversion_matrix = np.linalg.inv(M_dg @ M) @ M_dg
rho = linear_inversion_matrix @ p
rho = np.reshape(rho, (2**n, 2**n))

Thank you in advance for your answer!


1 Answer 1


IBMQJobManager.run() returns a ManagedResult, but StateTomographyFitter expects a Result object. Unfortunately there is no easy way to convert the former into the latter, so you'll have to combine the results yourself:

job_set = job_manager.run(qst, backend=device, name='foo',shots=8192)
jobs = job_set.jobs()
new_result = copy.deepcopy(jobs[0].result())
for idx in range(1, len(jobs)):
statefit = tomo.StateTomographyFitter(new_result, qst)

This is an interesting use case. Looks like Job Manager should really support returning a Result object.

  • $\begingroup$ Thank you for your help, my only question is in the last line, where you have written job.results() it should be something else as no variable called job is defined. $\endgroup$
    – Paula G
    Jun 2, 2020 at 8:45
  • $\begingroup$ Oops copy & paste error. Updated to use the new_result that has combined results from all jobs. $\endgroup$
    – jyu00
    Jun 3, 2020 at 12:47
  • $\begingroup$ Thank you again. I still have a problem because when I run the code I get the following error: The Qobj uses gates (['h', 'sdg']) that are not among the basis gates (['u1', 'u2', 'u3', 'cx', 'id']) [1106]. I have unrolled the quantum circuit object in these basis gates and I have checked that it has been done propertly. Anyway it does not work. $\endgroup$
    – Paula G
    Jun 4, 2020 at 13:39
  • $\begingroup$ Unlike execute, IBMQJobManager.run() doesn't transpile the circuits for you (e.g. no gate unrolling), so you'll have to do that yourself. Can you check that all circuits in qst have been unrolled to the basis gates? $\endgroup$
    – jyu00
    Jun 5, 2020 at 14:31
  • $\begingroup$ I changed this: pass_ = Unroller(['u1', 'u2', 'u3', 'cx', 'id']) pm = PassManager([pass_]) circ = pm.run(qc) qst = tomo.state_tomography_circuits(circ, qr) $\endgroup$
    – Paula G
    Jun 5, 2020 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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